@@ -141,7 +141,7 @@ impl<T> OnceLock<T> {
141
141
142
142
/// Gets the reference to the underlying value.
143
143
///
144
- /// Returns `None` if the cell is empty, or being initialized . This
144
+ /// Returns `None` if the cell is empty, or being set . This
145
145
/// method never blocks.
146
146
#[ inline]
147
147
#[ stable( feature = "once_cell" , since = "1.70.0" ) ]
@@ -168,7 +168,7 @@ impl<T> OnceLock<T> {
168
168
}
169
169
}
170
170
171
- /// Blocks the current thread until the cell is initialized .
171
+ /// Blocks the current thread until the cell is set .
172
172
///
173
173
/// # Example
174
174
///
@@ -198,8 +198,8 @@ impl<T> OnceLock<T> {
198
198
199
199
/// Sets the contents of this cell to `value`.
200
200
///
201
- /// May block if another thread is currently attempting to initialize the cell. The cell is
202
- /// guaranteed to contain a value when set returns, though not necessarily the one provided.
201
+ /// May block if another thread is currently attempting to set the cell. The cell is
202
+ /// guaranteed to contain a value when ` set` returns, though not necessarily the one provided.
203
203
///
204
204
/// Returns `Ok(())` if the cell's value was set by this call.
205
205
///
@@ -233,10 +233,10 @@ impl<T> OnceLock<T> {
233
233
/// Sets the contents of this cell to `value` if the cell was empty, then
234
234
/// returns a reference to it.
235
235
///
236
- /// May block if another thread is currently attempting to initialize the cell. The cell is
237
- /// guaranteed to contain a value when set returns, though not necessarily the one provided.
236
+ /// May block if another thread is currently attempting to set the cell. The cell is
237
+ /// guaranteed to contain a value when ` set` returns, though not necessarily the one provided.
238
238
///
239
- /// Returns `Ok(&value)` if the cell was empty and `Err(¤t_value, value)` if it was full .
239
+ /// Returns `Ok(&value)` if the cell was empty and `Err(¤t_value, value)` if it was set .
240
240
///
241
241
/// # Examples
242
242
///
@@ -269,19 +269,19 @@ impl<T> OnceLock<T> {
269
269
}
270
270
}
271
271
272
- /// Gets the contents of the cell, initializing it with `f` if the cell
272
+ /// Gets the contents of the cell, setting it with `f` if the cell
273
273
/// was empty.
274
274
///
275
275
/// Many threads may call `get_or_init` concurrently with different
276
- /// initializing functions, but it is guaranteed that only one function
276
+ /// setting functions, but it is guaranteed that only one function
277
277
/// will be executed.
278
278
///
279
279
/// # Panics
280
280
///
281
281
/// If `f` panics, the panic is propagated to the caller, and the cell
282
- /// remains uninitialized .
282
+ /// remains empty .
283
283
///
284
- /// It is an error to reentrantly initialize the cell from `f`. The
284
+ /// It is an error to reentrantly set the cell from `f`. The
285
285
/// exact outcome is unspecified. Current implementation deadlocks, but
286
286
/// this may be changed to a panic in the future.
287
287
///
@@ -307,15 +307,15 @@ impl<T> OnceLock<T> {
307
307
}
308
308
}
309
309
310
- /// Gets the mutable reference of the contents of the cell, initializing
310
+ /// Gets the mutable reference of the contents of the cell, setting
311
311
/// it with `f` if the cell was empty.
312
312
///
313
313
/// This method never blocks.
314
314
///
315
315
/// # Panics
316
316
///
317
317
/// If `f` panics, the panic is propagated to the caller, and the cell
318
- /// remains uninitialized .
318
+ /// remains empty .
319
319
///
320
320
/// # Examples
321
321
///
@@ -345,16 +345,16 @@ impl<T> OnceLock<T> {
345
345
}
346
346
}
347
347
348
- /// Gets the contents of the cell, initializing it with `f` if
348
+ /// Gets the contents of the cell, setting it with `f` if
349
349
/// the cell was empty. If the cell was empty and `f` failed, an
350
350
/// error is returned.
351
351
///
352
352
/// # Panics
353
353
///
354
354
/// If `f` panics, the panic is propagated to the caller, and
355
- /// the cell remains uninitialized .
355
+ /// the cell remains empty .
356
356
///
357
- /// It is an error to reentrantly initialize the cell from `f`.
357
+ /// It is an error to reentrantly set the cell from `f`.
358
358
/// The exact outcome is unspecified. Current implementation
359
359
/// deadlocks, but this may be changed to a panic in the future.
360
360
///
@@ -396,7 +396,7 @@ impl<T> OnceLock<T> {
396
396
Ok ( unsafe { self . get_unchecked ( ) } )
397
397
}
398
398
399
- /// Gets the mutable reference of the contents of the cell, initializing
399
+ /// Gets the mutable reference of the contents of the cell, setting
400
400
/// it with `f` if the cell was empty. If the cell was empty and `f` failed,
401
401
/// an error is returned.
402
402
///
@@ -405,7 +405,7 @@ impl<T> OnceLock<T> {
405
405
/// # Panics
406
406
///
407
407
/// If `f` panics, the panic is propagated to the caller, and
408
- /// the cell remains uninitialized .
408
+ /// the cell remains empty .
409
409
///
410
410
/// # Examples
411
411
///
@@ -416,7 +416,7 @@ impl<T> OnceLock<T> {
416
416
///
417
417
/// let mut cell: OnceLock<u32> = OnceLock::new();
418
418
///
419
- /// // Failed initializers do not change the value
419
+ /// // Failed sets do not change the value
420
420
/// assert!(cell.get_mut_or_try_init(|| "not a number!".parse()).is_err());
421
421
/// assert!(cell.get().is_none());
422
422
///
@@ -460,9 +460,9 @@ impl<T> OnceLock<T> {
460
460
self . take ( )
461
461
}
462
462
463
- /// Takes the value out of this `OnceLock`, moving it back to an uninitialized state.
463
+ /// Takes the value out of this `OnceLock`, moving it back to an empty state.
464
464
///
465
- /// Has no effect and returns `None` if the `OnceLock` hasn't been initialized .
465
+ /// Has no effect and returns `None` if the `OnceLock` hasn't been set .
466
466
///
467
467
/// Safety is guaranteed by requiring a mutable reference.
468
468
///
@@ -528,7 +528,7 @@ impl<T> OnceLock<T> {
528
528
529
529
/// # Safety
530
530
///
531
- /// The value must be initialized
531
+ /// The value must be set
532
532
#[ inline]
533
533
unsafe fn get_unchecked ( & self ) -> & T {
534
534
debug_assert ! ( self . is_initialized( ) ) ;
@@ -537,7 +537,7 @@ impl<T> OnceLock<T> {
537
537
538
538
/// # Safety
539
539
///
540
- /// The value must be initialized
540
+ /// The value must be set
541
541
#[ inline]
542
542
unsafe fn get_unchecked_mut ( & mut self ) -> & mut T {
543
543
debug_assert ! ( self . is_initialized( ) ) ;
0 commit comments