@@ -22,12 +22,14 @@ pub use {
2222 ptr:: Ptr ,
2323} ;
2424
25+ use crate :: wrappers:: ReadOnly ;
26+
2527/// A shorthand for a maybe-valid, maybe-aligned reference. Used as the argument
2628/// to [`TryFromBytes::is_bit_valid`].
2729///
2830/// [`TryFromBytes::is_bit_valid`]: crate::TryFromBytes::is_bit_valid
2931pub type Maybe < ' a , T , Aliasing = invariant:: Shared , Alignment = invariant:: Unaligned > =
30- Ptr < ' a , T , ( Aliasing , Alignment , invariant:: Initialized ) > ;
32+ Ptr < ' a , ReadOnly < T > , ( Aliasing , Alignment , invariant:: Initialized ) > ;
3133
3234/// Checks if the referent is zeroed.
3335pub ( crate ) fn is_zeroed < T , I > ( ptr : Ptr < ' _ , T , I > ) -> bool
@@ -49,7 +51,7 @@ pub mod cast {
4951
5052 use crate :: {
5153 layout:: { SizeInfo , TrailingSliceLayout } ,
52- HasField , KnownLayout , PtrInner ,
54+ HasField , KnownLayout , PtrInner , REPR_C_UNION_VARIANT_ID ,
5355 } ;
5456
5557 /// A pointer cast or projection.
@@ -361,6 +363,15 @@ pub mod cast {
361363 }
362364 }
363365
366+ // SAFETY: TODO
367+ unsafe impl < W : ?Sized , F , const FIELD_ID : i128 >
368+ Cast < W , W :: WrappedField > for WrappedProjection < W , F , { REPR_C_UNION_VARIANT_ID } , FIELD_ID >
369+ where
370+ W : Wrapped
371+ + HasWrappedField < <<W as Wrapped >:: Unwrapped as HasField < F , { REPR_C_UNION_VARIANT_ID } , FIELD_ID > >:: Type > ,
372+ W :: Unwrapped : HasField < F , { REPR_C_UNION_VARIANT_ID } , FIELD_ID > ,
373+ { }
374+
364375 /// A transitive sequence of projections.
365376 ///
366377 /// Given `TU: Project` and `UV: Project`, `TransitiveProject<_, TU, UV>` is
0 commit comments