@@ -1035,7 +1035,7 @@ impl<T: ?Sized> DerefMut for ManuallyDrop<T> {
1035
1035
}
1036
1036
}
1037
1037
1038
- /// A newtype to construct uninitialized instances of `T`.
1038
+ /// A wrapper to construct uninitialized instances of `T`.
1039
1039
///
1040
1040
/// The compiler, in general, assumes that variables are properly initialized
1041
1041
/// at their respective type. For example, a variable of reference type must
@@ -1049,7 +1049,7 @@ impl<T: ?Sized> DerefMut for ManuallyDrop<T> {
1049
1049
/// use std::mem::{self, MaybeUninit};
1050
1050
///
1051
1051
/// let x: &i32 = unsafe { mem::zeroed() }; // undefined behavior!
1052
- /// // equivalent code with `MaybeUninit`
1052
+ /// // equivalent code with `MaybeUninit<&i32> `
1053
1053
/// let x: &i32 = unsafe { MaybeUninit::zeroed().into_initialized() }; // undefined behavior!
1054
1054
/// ```
1055
1055
///
@@ -1064,7 +1064,7 @@ impl<T: ?Sized> DerefMut for ManuallyDrop<T> {
1064
1064
/// use std::mem::{self, MaybeUninit};
1065
1065
///
1066
1066
/// let b: bool = unsafe { mem::uninitialized() }; // undefined behavior!
1067
- /// // The equivalent code with `MaybeUninit`:
1067
+ /// // The equivalent code with `MaybeUninit<bool> `:
1068
1068
/// let b: bool = unsafe { MaybeUninit::uninitialized().into_initialized() }; // undefined behavior!
1069
1069
/// ```
1070
1070
///
@@ -1078,7 +1078,7 @@ impl<T: ?Sized> DerefMut for ManuallyDrop<T> {
1078
1078
/// use std::mem::{self, MaybeUninit};
1079
1079
///
1080
1080
/// let x: i32 = unsafe { mem::uninitialized() }; // undefined behavior!
1081
- /// // equivalent code with `MaybeUninit`
1081
+ /// // equivalent code with `MaybeUninit<i32> `
1082
1082
/// let x: i32 = unsafe { MaybeUninit::uninitialized().into_initialized() }; // undefined behavior!
1083
1083
/// ```
1084
1084
/// (Notice that the rules around uninitialized integers are not finalized yet, but
@@ -1093,7 +1093,7 @@ impl<T: ?Sized> DerefMut for ManuallyDrop<T> {
1093
1093
/// use std::mem::MaybeUninit;
1094
1094
///
1095
1095
/// // Create an explicitly uninitialized reference. The compiler knows that data inside
1096
- /// // a `MaybeUninit` may be invalid, and hence this is not UB:
1096
+ /// // a `MaybeUninit<T> ` may be invalid, and hence this is not UB:
1097
1097
/// let mut x = MaybeUninit::<&i32>::uninitialized();
1098
1098
/// // Set it to a valid value.
1099
1099
/// x.set(&0);
@@ -1125,25 +1125,25 @@ impl<T: Copy> Clone for MaybeUninit<T> {
1125
1125
impl < T > MaybeUninit < T > {
1126
1126
/// Create a new `MaybeUninit<T>` initialized with the given value.
1127
1127
///
1128
- /// Note that dropping a `MaybeUninit` will never call `T`'s drop code.
1128
+ /// Note that dropping a `MaybeUninit<T> ` will never call `T`'s drop code.
1129
1129
/// It is your responsibility to make sure `T` gets dropped if it got initialized.
1130
1130
#[ unstable( feature = "maybe_uninit" , issue = "53491" ) ]
1131
1131
#[ inline( always) ]
1132
1132
pub const fn new ( val : T ) -> MaybeUninit < T > {
1133
1133
MaybeUninit { value : ManuallyDrop :: new ( val) }
1134
1134
}
1135
1135
1136
- /// Creates a new `MaybeUninit` in an uninitialized state.
1136
+ /// Creates a new `MaybeUninit<T> ` in an uninitialized state.
1137
1137
///
1138
- /// Note that dropping a `MaybeUninit` will never call `T`'s drop code.
1138
+ /// Note that dropping a `MaybeUninit<T> ` will never call `T`'s drop code.
1139
1139
/// It is your responsibility to make sure `T` gets dropped if it got initialized.
1140
1140
#[ unstable( feature = "maybe_uninit" , issue = "53491" ) ]
1141
1141
#[ inline( always) ]
1142
1142
pub const fn uninitialized ( ) -> MaybeUninit < T > {
1143
1143
MaybeUninit { uninit : ( ) }
1144
1144
}
1145
1145
1146
- /// Creates a new `MaybeUninit` in an uninitialized state, with the memory being
1146
+ /// Creates a new `MaybeUninit<T> ` in an uninitialized state, with the memory being
1147
1147
/// filled with `0` bytes. It depends on `T` whether that already makes for
1148
1148
/// proper initialization. For example, `MaybeUninit<usize>::zeroed()` is initialized,
1149
1149
/// but `MaybeUninit<&'static i32>::zeroed()` is not because references must not
@@ -1190,9 +1190,9 @@ impl<T> MaybeUninit<T> {
1190
1190
u
1191
1191
}
1192
1192
1193
- /// Sets the value of the `MaybeUninit`. This overwrites any previous value without dropping it.
1194
- /// For your convenience, this also returns a mutable reference to the (now safely initialized)
1195
- /// contents of `self`.
1193
+ /// Sets the value of the `MaybeUninit<T> `. This overwrites any previous value
1194
+ /// without dropping it. For your convenience, this also returns a mutable
1195
+ /// reference to the (now safely initialized) contents of `self`.
1196
1196
#[ unstable( feature = "maybe_uninit" , issue = "53491" ) ]
1197
1197
#[ inline( always) ]
1198
1198
pub fn set ( & mut self , val : T ) -> & mut T {
@@ -1215,7 +1215,7 @@ impl<T> MaybeUninit<T> {
1215
1215
///
1216
1216
/// let mut x = MaybeUninit::<Vec<u32>>::uninitialized();
1217
1217
/// x.set(vec![0,1,2]);
1218
- /// // Create a reference into the `MaybeUninit`. This is okay because we initialized it.
1218
+ /// // Create a reference into the `MaybeUninit<T> `. This is okay because we initialized it.
1219
1219
/// let x_vec = unsafe { &*x.as_ptr() };
1220
1220
/// assert_eq!(x_vec.len(), 3);
1221
1221
/// ```
@@ -1272,13 +1272,13 @@ impl<T> MaybeUninit<T> {
1272
1272
unsafe { & mut * self . value as * mut T }
1273
1273
}
1274
1274
1275
- /// Extracts the value from the `MaybeUninit` container. This is a great way
1275
+ /// Extracts the value from the `MaybeUninit<T> ` container. This is a great way
1276
1276
/// to ensure that the data will get dropped, because the resulting `T` is
1277
1277
/// subject to the usual drop handling.
1278
1278
///
1279
1279
/// # Unsafety
1280
1280
///
1281
- /// It is up to the caller to guarantee that the `MaybeUninit` really is in an initialized
1281
+ /// It is up to the caller to guarantee that the `MaybeUninit<T> ` really is in an initialized
1282
1282
/// state. Calling this when the content is not yet fully initialized causes undefined
1283
1283
/// behavior.
1284
1284
///
@@ -1374,7 +1374,7 @@ impl<T> MaybeUninit<T> {
1374
1374
///
1375
1375
/// # Unsafety
1376
1376
///
1377
- /// It is up to the caller to guarantee that the `MaybeUninit` really is in an initialized
1377
+ /// It is up to the caller to guarantee that the `MaybeUninit<T> ` really is in an initialized
1378
1378
/// state. Calling this when the content is not yet fully initialized causes undefined
1379
1379
/// behavior.
1380
1380
#[ unstable( feature = "maybe_uninit_ref" , issue = "53491" ) ]
@@ -1387,7 +1387,7 @@ impl<T> MaybeUninit<T> {
1387
1387
///
1388
1388
/// # Unsafety
1389
1389
///
1390
- /// It is up to the caller to guarantee that the `MaybeUninit` really is in an initialized
1390
+ /// It is up to the caller to guarantee that the `MaybeUninit<T> ` really is in an initialized
1391
1391
/// state. Calling this when the content is not yet fully initialized causes undefined
1392
1392
/// behavior.
1393
1393
// FIXME(#53491): We currently rely on the above being incorrect, i.e., we have references
0 commit comments