Skip to content

Should we use MaybeUnint? #469

Open
Open
@Kixunil

Description

@Kixunil

At first I thought MaybeUninit isn't used out of paranoia but now I realized it was because of MSRV. We can use it now. There's a bunch of places where it should be usable - mainly out parameters in C functions.

Pros/cons/thoughts:

  • Faster, even without cross-language LTO
  • Probably less burden on optimizer
  • Expresses the intent better
  • Another possible source of UB, but should be simple to handle
  • We have to make sure the C library overwrites the memory - maybe we need to ask for guarantees upstream
  • Things like "left in unspecified state if fails" are OK we just have to call assume_init only on success
  • Perhaps we can improve things using a macro

I personally prefer to do it if upstream can guarantee at least that if a call succeeds the memory is fully overwritten.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions