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
These are old notes from when we were designing TryFromBytes based on a MaybeValid type, and trying to support MaybeValid<T> for T: ?Sized. They're no longer relevant, but I'm putting them here for posterity.
It seems like, even with a KnownLayout custom derive, there'll be no way to teach Rust that T: Sized => MaybeUninit<T>: Sized.
One potential alternative: Instead of a KnownLayout w/ custom derive, just wait until ptr_metadata is stabilized. Until then, TryFromBytes supports T: Sized and [T].
One potential problem with this approach: As currently implemented, Sized does not imply Pointee<Metadata = ()>. Thus, the following has an impl conflict without the Pointee<Metadata = ()> bound in the first impl block. This implies that uses of MaybeUninit which require MaybeUninit<T>: Sized will be impossible in a generic context without a separate Pointee<Metadata = ()> bound.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
These are old notes from when we were designing
TryFromBytesbased on aMaybeValidtype, and trying to supportMaybeValid<T>forT: ?Sized. They're no longer relevant, but I'm putting them here for posterity.It seems like, even with a
KnownLayoutcustom derive, there'll be no way to teach Rust thatT: Sized => MaybeUninit<T>: Sized.One potential alternative: Instead of a
KnownLayoutw/ custom derive, just wait untilptr_metadatais stabilized. Until then,TryFromBytessupportsT: Sizedand[T].One potential problem with this approach: As currently implemented,
Sizeddoes not implyPointee<Metadata = ()>. Thus, the following has an impl conflict without thePointee<Metadata = ()>bound in the first impl block. This implies that uses ofMaybeUninitwhich requireMaybeUninit<T>: Sizedwill be impossible in a generic context without a separatePointee<Metadata = ()>bound.Beta Was this translation helpful? Give feedback.
All reactions