1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
use Copy;
/// Unsafe marker trait for types that can be copied, including unsized types such as slices.
///
/// # Safety
///
/// The implementor must ensure `Self` has a memory representation which can be duplicated without
/// violating soundness or causing double frees.
pub unsafe
// SAFETY: Any `T` which is `Copy` is also `UnsizedCopy`.
unsafe
// SAFETY: And so are slices containing copyable T.
unsafe
// SAFETY: `str == [u8]` and `u8: Copy`, so, above.
unsafe
// SAFETY: `CStr == [u8]`
unsafe
// SAFETY: `OsStr == [u8]`
unsafe
// SAFETY: `Path == OsStr == [u8]`
unsafe
/// Trait indicating that a type has no metadata.
///
/// This usually means `Self: Sized` or `Self` is `extern`.
///
/// # Safety
///
/// The implementor must ensure this type has no metadata (`<Self as Pointee>::Metadata = ()`).
///
/// # Example
///
/// ```
/// # use memapi2::traits::data::{marker::Thin, type_props::SizedProps};
///
/// fn never_panics<T: Thin>() {
/// assert_eq!(<&T>::SZ, usize::SZ)
/// }
/// ```
pub unsafe
/// Trait indicating that a type has no metadata.
///
/// This usually means `Self: Sized` or `Self` is `extern`.
///
/// # Safety
///
/// This is safe to implement in this configuration; however, because the actually unsafe
/// version exists when both `metadata` and `sized_hierarchy` are disabled, this trait
/// must still be marked `unsafe` for consistency across configurations.
///
/// # Example
///
/// ```
/// # use memapi2::traits::{data::type_props::SizedProps, data::marker::Thin};
///
/// fn never_panics<T: Thin>() {
/// assert_eq!(<&T>::SZ, usize::SZ)
/// }
/// ```
pub unsafe
/// Trait indicating that a type has no metadata and may or may not have a size.
///
/// # Safety
///
/// This is safe to implement in this configuration; however, because the actually unsafe
/// version exists when both `metadata` and `sized_hierarchy` are disabled, this trait
/// must still be marked `unsafe` for consistency across configurations.
///
/// # Example
///
/// ```
/// # use memapi2::{traits::data::{type_props::SizedProps, marker::{SizeMeta, Thin}}};
///
/// fn never_panics<T: Thin>() {
/// assert_eq!(<&T>::SZ, usize::SZ)
/// }
/// ```
pub unsafe
/// Trait indicating that a type has `usize` metadata.
///
/// # Safety
///
/// The implementor must ensure this type has `usize` metadata (`<Self as Pointee>::Metadata =
/// usize`).
///
/// # Example
///
/// ```
/// # use memapi2::{traits::data::{type_props::SizedProps, marker::SizeMeta}};
///
/// fn never_panics<T: SizeMeta>() {
/// assert_eq!(<&T>::SZ, usize::SZ * 2)
/// }
/// ```
pub unsafe
/// Trait indicating that a type has `usize` metadata.
///
/// # Safety
///
/// The implementor must ensure this type has `usize` metadata (`<Self as Pointee>::Metadata =
/// usize`).
///
/// # Example
///
/// ```
/// # use memapi2::{traits::data::{type_props::SizedProps, marker::SizeMeta}};
///
/// fn never_panics<T: SizeMeta>() {
/// assert_eq!(<&T>::SZ, usize::SZ * 2)
/// }
/// ```
pub unsafe
/// Trait indicating that a type has `usize` metadata.
///
/// # Safety
///
/// This is safe to implement in this configuration; however, because the actually unsafe version
/// exists when `metadata` is disabled, this trait must still be marked `unsafe` for consistency
/// across configurations.
///
/// # Example
///
/// ```
/// # use memapi2::{traits::data::{type_props::SizedProps, marker::SizeMeta}};
///
/// fn never_panics<T: SizeMeta>() {
/// assert_eq!(<&T>::SZ, usize::SZ * 2)
/// }
/// ```
pub unsafe
/// Trait indicating that a type has `usize` metadata.
///
/// # Safety
///
/// This is safe to implement in this configuration; however, because the actually unsafe version
/// exists when `metadata` is disabled, this trait must still be marked `unsafe` for consistency
/// across configurations.
///
/// # Example
///
/// ```
/// # use memapi2::{traits::data::{type_props::SizedProps, marker::SizeMeta}};
///
/// fn never_panics<T: SizeMeta>() {
/// assert_eq!(<&T>::SZ, usize::SZ * 2)
/// }
/// ```
pub unsafe
// SAFETY: `P: Pointee<Metadata = ()>`
unsafe
// SAFETY: `P: Pointee<Metadata = usize>`
unsafe