Lines Matching full:project

59     /// The implementation of `project` must satisfy its safety post-condition.
60 pub unsafe trait Project<Src: ?Sized, Dst: ?Sized> { trait
63 /// Users should generally not call `project` directly, and instead
64 /// should use high-level APIs like [`PtrInner::project`] or
65 /// [`Ptr::project`].
67 /// [`Ptr::project`]: crate::pointer::Ptr::project
73 fn project(src: PtrInner<'_, Src>) -> *mut Dst; in project() method
76 /// A [`Project`] which preserves the address of the referent – a pointer
83 pub unsafe trait Cast<Src: ?Sized, Dst: ?Sized>: Project<Src, Dst> {}
97 // SAFETY: `project` returns its argument unchanged, and so it is a
100 unsafe impl<T: ?Sized> Project<T, T> for IdCast {
102 fn project(src: PtrInner<'_, T>) -> *mut T { in project() method
107 // SAFETY: The `Project::project` impl preserves referent address.
110 // SAFETY: The `Project::project` impl preserves referent size.
118 /// The implementation of [`Project`] uses a compile-time assertion to
120 /// sound implementation of [`Project`] for all `Src` and `Dst` – the caller
128 unsafe impl<Src, Dst> Project<Src, Dst> for CastSized {
130 fn project(src: PtrInner<'_, Src>) -> *mut Dst { in project() method
136 // SAFETY: The `Project::project` impl preserves referent address.
144 /// The implementation of [`Project`] uses a compile-time assertion to
146 /// has a sound implementation of [`Project`] for all `Src` and `Dst` – the
155 unsafe impl<Src, Dst> Project<Src, Dst> for CastSizedExact {
157 fn project(src: PtrInner<'_, Src>) -> *mut Dst { in project() method
163 // SAFETY: The `Project::project_raw` impl preserves referent address.
166 // SAFETY: By the `static_assert!`, `Project::project_raw` impl preserves
175 /// The implementation of [`Project`] uses a compile-time assertion to
177 /// `CastUnsized` has a sound implementation of [`Project`] for all `Src`
189 // trailing padding). Thus, `project` preserves the set of referent bytes.
190 unsafe impl<Src, Dst> Project<Src, Dst> for CastUnsized
196 fn project(src: PtrInner<'_, Src>) -> *mut Dst { in project() function
217 // SAFETY: The `Project::project` impl preserves referent address.
225 // SAFETY: By the `static_assert!` in `Project::project`, `Src` and `Dst`
241 /// A `Projection` is a [`Project`] which implements projection by
242 /// delegating to an implementation of [`HasField::project`].
249 // SAFETY: `HasField::project` has the same safety post-conditions as
250 // `Project::project`.
251 unsafe impl<T: ?Sized, F, const VARIANT_ID: i128, const FIELD_ID: i128> Project<T, T::Type> impl
257 fn project(src: PtrInner<'_, T>) -> *mut T::Type { in project() function
258 T::project(src) in project()
304 /// Given `TU: Project` and `UV: Project`, `TransitiveProject<_, TU, UV>` is
305 /// a [`Project`] which projects by applying `TU` followed by `UV`.
318 // SAFETY: Since `TU::project` and `UV::project` are each
321 unsafe impl<T, U, V, TU, UV> Project<T, V> for TransitiveProject<U, TU, UV>
326 TU: Project<T, U>,
327 UV: Project<U, V>,
330 fn project(t: PtrInner<'_, T>) -> *mut V { in project() function
331 t.project::<_, TU>().project::<_, UV>().as_ptr() in project()
335 // SAFETY: Since the `Project::project` impl delegates to `TU::project` and
336 // `UV::project`, and since `TU` and `UV` are `Cast`, the `Project::project`
348 // SAFETY: Since the `Project::project` impl delegates to `TU::project` and
349 // `UV::project`, and since `TU` and `UV` are `CastExact`, the `Project::project`
365 // SAFETY: `project` constructs a pointer with the same address as `src`
372 unsafe impl<T: ?Sized + KnownLayout> Project<T, [u8]> for AsBytesCast {
374 fn project(src: PtrInner<'_, T>) -> *mut [u8] { in project() method
389 // SAFETY: The `Project::project` impl preserves referent address.
392 // SAFETY: The `Project::project` impl preserves the set of referent bytes.
399 // SAFETY: The `project` implementation projects to a subset of its
401 unsafe impl<T: ?Sized> Project<T, ()> for CastToUnit {
403 fn project(src: PtrInner<'_, T>) -> *mut () { in project() method
408 // SAFETY: The `project` implementation preserves referent address.