matklad / once_cell

Rust library for single assignment cells and lazy statics without macros
Apache License 2.0
1.87k stars 109 forks source link

Allow unsized types for OnceBox and OnceRef #225

Closed neoeinstein closed 1 year ago

neoeinstein commented 1 year ago

Because both of these types are held behind a reference, they should be able to accept unsized types, allowing for things like OnceBox<str> or OnceBox<'static, str>.

matklad commented 1 year ago

I am not sure that'll work: we use pointer CAS in the implementation, so we need the pointer to be a narrow one.

qwandor commented 1 year ago

Being able to use OnceBox<dyn MyTrait> or OnceRef<dyn MyTrait> would also be useful, and seems to be blocked for the same reason.

matklad commented 1 year ago

Yeah, I don't think this could work