Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prototype for MaybeUninit formulation of arrayvec #76

Closed
wants to merge 3 commits into from
Closed

Conversation

bluss
Copy link
Owner

@bluss bluss commented Oct 20, 2017

  • Testing ideas for arrayvec 1.0
  • Looking at what is well defined and what's not
  • Not adequate yet:
    • How to handle uninitialization?
    • How to handle ArrayString? It's Copy & uninitialized (always an array of u8)

@bluss
Copy link
Owner Author

bluss commented Oct 20, 2017

cc @arielb1 and thanks a lot for the help in searching for the best expression of this in Rust

- Testing ideas for arrayvec 1.0
- Looking at what is well defined and what's not
@tbu-
Copy link
Collaborator

tbu- commented Oct 21, 2017

Is the repr(C) supposed to inhibit the enum optimization?

@bluss
Copy link
Owner Author

bluss commented Oct 21, 2017

repr(C) was put there only there so that we can cast the *const MaybeUninit<T> to *const T. There is a missing link right now, that needs to be rationalized as sound for the intermediate ManuallyDrop too.

@bluss
Copy link
Owner Author

bluss commented Oct 21, 2017

A question I didn't fully understand if it was answered:

If we have a MaybeUninit<[T; 3]> which is partially initialized; only its first element is initialized.

  1. Is it sound to extract a &[T; 3] from this?
  2. Must arrayvec instead extract a *const T? (With the eventual goal of course, of creating &T to an element only if that element is initialized.)

I think the following would be problematic if answered with no:

  1. Is it sound to call <[_]>::as_ptr() on a partially initialized [T; 3]?

@bluss
Copy link
Owner Author

bluss commented Oct 21, 2017

@tbu-
Copy link
Collaborator

tbu- commented Oct 21, 2017

Thanks for the link to the discussion. Sounds like having a &[T; 3] with uninitialized elements is UB or at least not clearly not UB. We could work with *mut [T; 3] and *mut [T].

@bluss
Copy link
Owner Author

bluss commented Oct 21, 2017

What we were trying to do is to get docs amended for ManuallyDrop so that it can be "MaybeUnitialized", but that seems to not be such a good idea. I'm still not entirely convinced.

@bluss
Copy link
Owner Author

bluss commented Mar 25, 2018

New version in #97

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants