pub trait ProjectionExt: Projection {
// Provided methods
unsafe fn borrow<'a, X, Y>(&self, ptr: *const X) -> Y
where X: HasPlace<Target = Self::Source> + PlaceBorrow<'a, Self, Y>,
Y: HasPlace<Target = Self::Target> { ... }
unsafe fn read<X>(&self, ptr: *const X) -> Self::Target
where X: PlaceRead<Self>,
Self::Target: Sized { ... }
unsafe fn write<X>(&self, ptr: *mut X, val: Self::Target)
where X: PlaceWrite<Self>,
Self::Target: Sized { ... }
unsafe fn deref<X>(&self, ptr: *mut X) -> *const Self::Target
where X: HasPlace<Target = Self::Source> + PlaceDeref<Self>,
Self::Target: HasPlace { ... }
fn as_sized(&self) -> SizedProj<Self::Source, Self::Target>
where Self::Source: Sized,
Self::Target: Sized { ... }
fn compose<Q>(self, other: Q) -> ComposeProj<Self, Q>
where Self: Sized,
Q: Projection<Source = Self::Target> { ... }
}Provided Methods§
Sourceunsafe fn borrow<'a, X, Y>(&self, ptr: *const X) -> Ywhere
X: HasPlace<Target = Self::Source> + PlaceBorrow<'a, Self, Y>,
Y: HasPlace<Target = Self::Target>,
unsafe fn borrow<'a, X, Y>(&self, ptr: *const X) -> Ywhere
X: HasPlace<Target = Self::Source> + PlaceBorrow<'a, Self, Y>,
Y: HasPlace<Target = Self::Target>,
Convenience method that simply calls the corresponding PlaceBorrow method.
Sourceunsafe fn read<X>(&self, ptr: *const X) -> Self::Target
unsafe fn read<X>(&self, ptr: *const X) -> Self::Target
Convenience method that simply calls the corresponding PlaceRead method.
Sourceunsafe fn write<X>(&self, ptr: *mut X, val: Self::Target)
unsafe fn write<X>(&self, ptr: *mut X, val: Self::Target)
Convenience method that simply calls the corresponding PlaceRead method.
Sourceunsafe fn deref<X>(&self, ptr: *mut X) -> *const Self::Target
unsafe fn deref<X>(&self, ptr: *mut X) -> *const Self::Target
Convenience method that simply calls the corresponding PlaceDeref method.
Sourcefn as_sized(&self) -> SizedProj<Self::Source, Self::Target>
fn as_sized(&self) -> SizedProj<Self::Source, Self::Target>
When the target is sized, we know a projection is just an offset so we
can make it sized even if we had a dyn Projection.
Definitely a bit hacky.
fn compose<Q>(self, other: Q) -> ComposeProj<Self, Q>
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
impl<P: Projection + ?Sized> ProjectionExt for P
Extension trait so that Projection stays dyn-compatible.