We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 1265cbf commit 102ee5eCopy full SHA for 102ee5e
src/libcore/convert.rs
@@ -92,6 +92,22 @@ pub trait AsRef<T: ?Sized> {
92
/// [`Option<T>`]: ../../std/option/enum.Option.html
93
/// [`Result<T, E>`]: ../../std/result/enum.Result.html
94
///
95
+/// # Examples
96
+///
97
+/// [`Box<T>`] implements `AsMut<T>`:
98
99
+/// [`Box<T>`]: ../../std/boxed/struct.Box.html
100
101
+/// ```
102
+/// fn add_one<T: AsMut<u64>>(num: &mut T) {
103
+/// *num.as_mut() += 1;
104
+/// }
105
106
+/// let mut boxed_num = Box::new(0);
107
+/// add_one(&mut boxed_num);
108
+/// assert_eq!(*boxed_num, 1);
109
110
111
/// # Generic Impls
112
113
/// - `AsMut` auto-dereferences if the inner type is a reference or a mutable
0 commit comments