You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's implemented for raw pointers, references, boxes, Rc, Arc, NonZero, and Shared. Is there a specific reason it can't be implemented for Unique?
As it stands, you can't actually reimplement something like Box the same way the standard library does. Somehow, even though a Box is just a wrapper around Unique, it can be coerced to an unsized type due to some compiler magic.
The following is paraphrased from the Box source, but does not compile:
use std::marker::Unsize;use std::ops::CoerceUnsized;use std::ptr::Unique;pubstructMyBox<T: ?Sized>(Unique<T>);impl<T: ?Sized+Unsize<U>,U: ?Sized>CoerceUnsized<MyBox<U>>forMyBox<T>{}fnmain(){}
The text was updated successfully, but these errors were encountered:
It's implemented for raw pointers, references, boxes, Rc, Arc, NonZero, and Shared. Is there a specific reason it can't be implemented for Unique?
As it stands, you can't actually reimplement something like Box the same way the standard library does. Somehow, even though a Box is just a wrapper around Unique, it can be coerced to an unsized type due to some compiler magic.
The following is paraphrased from the Box source, but does not compile:
The text was updated successfully, but these errors were encountered: