Skip to main content

ProjectionExt

Trait ProjectionExt 

Source
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§

Source

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

Convenience method that simply calls the corresponding PlaceBorrow method.

Source

unsafe fn read<X>(&self, ptr: *const X) -> Self::Target
where X: PlaceRead<Self>, Self::Target: Sized,

Convenience method that simply calls the corresponding PlaceRead method.

Source

unsafe fn write<X>(&self, ptr: *mut X, val: Self::Target)
where X: PlaceWrite<Self>, Self::Target: Sized,

Convenience method that simply calls the corresponding PlaceRead method.

Source

unsafe fn deref<X>(&self, ptr: *mut X) -> *const Self::Target
where X: HasPlace<Target = Self::Source> + PlaceDeref<Self>, Self::Target: HasPlace,

Convenience method that simply calls the corresponding PlaceDeref method.

Source

fn as_sized(&self) -> SizedProj<Self::Source, Self::Target>
where Self::Source: Sized, Self::Target: Sized,

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.

Source

fn compose<Q>(self, other: Q) -> ComposeProj<Self, Q>
where Self: Sized, Q: Projection<Source = Self::Target>,

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<P: Projection + ?Sized> ProjectionExt for P

Extension trait so that Projection stays dyn-compatible.