matklad / once_cell

Rust library for single assignment cells and lazy statics without macros

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Allow unsized types for OnceBox and OnceRef

neoeinstein opened this issue · comments

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>.

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

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

Yeah, I don't think this could work