@@ -3,30 +3,30 @@ use crate::{
33 marker:: { Field , PinableField , UnalignedField } ,
44} ;
55
6- /// Type supporting projections.
6+ /// Type supporting field projections.
77///
8- /// The exact kind of projection is governed by [`Project`] and [`ProjectMut`]. This trait only
9- /// gives the compiler access to the `Self::Inner` type which is the type containing the projected
10- /// fields. So given an expression `base` of type `Self`, then the `field` ident in the expressions
11- /// `@base->field` and `@mut base->field` refer to a field of the type `Self::Inner`.
8+ /// The exact kind of field projection is governed by [`Project`] and [`ProjectMut`]. This trait
9+ /// only gives the compiler access to the `Self::Inner` type which is the type containing the
10+ /// potentially projectable fields. So given an expression `base` of type `Self`, then the `field`
11+ /// ident in the expressions `@base->field` and `@mut base->field` refer to a field of the type
12+ /// `Self::Inner`.
13+ ///
14+ /// If the projection `@base->field` is available still depends on weather `Self` implements
15+ /// `Project<field_of!(Self::Inner, field)>`.
1216pub trait Projectable : Sized {
1317 type Inner : ?Sized ;
1418}
1519
16- /// Marks project operations as safe.
20+ /// Marks project operations on `Self` as safe.
1721///
1822/// # Safety
1923///
20- /// * The `@base->field` and `@mut base->field` operations implemented by the [`Project`] and
21- /// [`ProjectMut`] traits must not have additional safety requirements.
24+ /// * The [`Project::project`] and [`ProjectMut::project_mut`] functions implemented for `Self`
25+ /// must not have additional safety requirements.
2226pub unsafe trait SafeProject : Projectable { }
2327
2428/// Shared projection operation `@base->field`.
25- ///
26- /// # Safety
27- ///
28- ///
29- pub unsafe trait Project < F > : Projectable
29+ pub trait Project < F > : Projectable
3030where
3131 F : UnalignedField < Base = Self :: Inner > ,
3232{
@@ -39,21 +39,19 @@ where
3939 ///
4040 /// # Safety
4141 ///
42- /// * `this` must be a dereferenceable pointer pointing at a valid value of `Self`.
42+ /// * `this` must be a valid pointer pointing at a valid value of `Self`.
4343 /// * for the duration of `'a`, the value at `this` is only used by other projection
4444 /// operations.
4545 /// * for the duration of `'a`, the value at `this` is not mutably projected with `F`.
46+ /// * Implementers may impose additional safety requirements. These must be documented on the
47+ /// implementation of this trait.
4648 unsafe fn project < ' a > ( this : * const Self ) -> Self :: Output < ' a >
4749 where
4850 Self : ' a ;
4951}
5052
5153/// Exclusive projection operation `@mut base->field`.
52- ///
53- /// # Safety
54- ///
55- ///
56- pub unsafe trait ProjectMut < F > : Projectable
54+ pub trait ProjectMut < F > : Projectable
5755where
5856 F : UnalignedField < Base = Self :: Inner > ,
5957{
6664 ///
6765 /// # Safety
6866 ///
69- /// * `this` must be a dereferenceable pointer pointing at a valid value of `Self`.
70- /// * for the duration of `'a`, the value at `this` is only used by other projection
67+ /// * `this` must be a valid pointer pointing at a valid value of `Self`.
68+ /// * For the duration of `'a`, the value at `this` is only used by other projection
7169 /// operations for fields other than `F`.
70+ /// * Implementers may impose additional safety requirements. These must be documented on the
71+ /// implementation of this trait.
7272 unsafe fn project_mut < ' a > ( this : * mut Self ) -> Self :: OutputMut < ' a >
7373 where
7474 Self : ' a ;
0 commit comments