@@ -3,30 +3,30 @@ use crate::{
3
3
marker:: { Field , PinableField , UnalignedField } ,
4
4
} ;
5
5
6
- /// Type supporting projections.
6
+ /// Type supporting field projections.
7
7
///
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)>`.
12
16
pub trait Projectable : Sized {
13
17
type Inner : ?Sized ;
14
18
}
15
19
16
- /// Marks project operations as safe.
20
+ /// Marks project operations on `Self` as safe.
17
21
///
18
22
/// # Safety
19
23
///
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.
22
26
pub unsafe trait SafeProject : Projectable { }
23
27
24
28
/// Shared projection operation `@base->field`.
25
- ///
26
- /// # Safety
27
- ///
28
- ///
29
- pub unsafe trait Project < F > : Projectable
29
+ pub trait Project < F > : Projectable
30
30
where
31
31
F : UnalignedField < Base = Self :: Inner > ,
32
32
{
@@ -39,21 +39,19 @@ where
39
39
///
40
40
/// # Safety
41
41
///
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`.
43
43
/// * for the duration of `'a`, the value at `this` is only used by other projection
44
44
/// operations.
45
45
/// * 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.
46
48
unsafe fn project < ' a > ( this : * const Self ) -> Self :: Output < ' a >
47
49
where
48
50
Self : ' a ;
49
51
}
50
52
51
53
/// Exclusive projection operation `@mut base->field`.
52
- ///
53
- /// # Safety
54
- ///
55
- ///
56
- pub unsafe trait ProjectMut < F > : Projectable
54
+ pub trait ProjectMut < F > : Projectable
57
55
where
58
56
F : UnalignedField < Base = Self :: Inner > ,
59
57
{
66
64
///
67
65
/// # Safety
68
66
///
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
71
69
/// operations for fields other than `F`.
70
+ /// * Implementers may impose additional safety requirements. These must be documented on the
71
+ /// implementation of this trait.
72
72
unsafe fn project_mut < ' a > ( this : * mut Self ) -> Self :: OutputMut < ' a >
73
73
where
74
74
Self : ' a ;
0 commit comments