We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 3fe52dd commit 05b7967Copy full SHA for 05b7967
text/0000-as-cell.md
@@ -167,7 +167,22 @@ an example implementation and a more complex use case.
167
[alternatives]: #alternatives
168
169
Instead of a dedicated trait, the functionality could be provided
170
-by standalone functions like this:
+as `Cell` constructors:
171
+
172
+```rust
173
174
+impl<T: Copy> Cell<T> {
175
+ fn from_mut<'a>(t: &'a mut T) -> &'a Cell<T> {
176
+ unsafe { mem::transmute(t) }
177
+ }
178
+ fn from_mut<'a>(t: &'a mut [T]) -> &'a [Cell<T>] {
179
180
181
+}
182
183
+```
184
185
+Or more simple, by standalone functions like this:
186
187
```rust
188
fn ref_as_cell<T: Copy>(t: &mut T) -> &Cell<T> {
0 commit comments