File tree 1 file changed +6
-0
lines changed
1 file changed +6
-0
lines changed Original file line number Diff line number Diff line change @@ -1327,13 +1327,19 @@ impl<T> Unalign<T> {
1327
1327
1328
1328
/// Updates the inner `T` by calling a function on it.
1329
1329
///
1330
+ /// If [`T: Unaligned`], then `Unalign<T>` implements [`DerefMut`], and that
1331
+ /// impl should be preferred over this method when performing updates, as it
1332
+ /// will usually be faster and more ergonomic.
1333
+ ///
1330
1334
/// For large types, this method may be expensive, as it requires copying
1331
1335
/// `2 * size_of::<T>()` bytes. \[1\]
1332
1336
///
1333
1337
/// \[1\] Since the inner `T` may not be aligned, it would not be sound to
1334
1338
/// invoke `f` on it directly. Instead, `update` moves it into a
1335
1339
/// properly-aligned location in the local stack frame, calls `f` on it, and
1336
1340
/// then moves it back to its original location in `self`.
1341
+ ///
1342
+ /// [`T: Unaligned`]: Unaligned
1337
1343
pub fn update < O , F : FnOnce ( & mut T ) -> O > ( & mut self , f : F ) -> O {
1338
1344
// On drop, this moves `copy` out of itself and uses `ptr::write` to
1339
1345
// overwrite `slf`.
You can’t perform that action at this time.
0 commit comments