Rollup merge of #108356 - gftea:master, r=workingjubilee

improve doc test for UnsafeCell::raw_get

improve docs of public API `UnsafeCell::raw_get`
This commit is contained in:
Matthias Krüger
2023-05-15 17:12:44 +02:00
committed by GitHub
2 changed files with 3 additions and 1 deletions

View File

@@ -2100,6 +2100,8 @@ impl<T: ?Sized> UnsafeCell<T> {
///
/// let m = MaybeUninit::<UnsafeCell<i32>>::uninit();
/// unsafe { UnsafeCell::raw_get(m.as_ptr()).write(5); }
/// // avoid below which references to uninitialized data
/// // unsafe { UnsafeCell::get(&*m.as_ptr()).write(5); }
/// let uc = unsafe { m.assume_init() };
///
/// assert_eq!(uc.into_inner(), 5);