Skip to content

Commit 5ed5bb8

Browse files
fixup! Add "OnceList" example to motivate OnceLock
1 parent e3d63d7 commit 5ed5bb8

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

library/std/src/sync/once_lock.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ use crate::sync::Once;
4747
/// You can use `OnceLock` to implement a type that requires "append-only" logic:
4848
///
4949
/// ```
50-
/// #![feature(once_cell_try_insert)]
5150
/// use std::sync::{OnceLock, atomic::{AtomicU32, Ordering}};
5251
/// use std::thread;
5352
///
@@ -62,7 +61,7 @@ use crate::sync::Once;
6261
/// fn push(&self, value: T) {
6362
/// // FIXME: this impl is concise, but is also slow for long lists or many threads.
6463
/// // as an exercise, consider how you might improve on it while preserving the behavior
65-
/// if let Err((_, value)) = self.data.try_insert(value) {
64+
/// if let Err(value) = self.data.set(value) {
6665
/// let next = self.next.get_or_init(|| Box::new(OnceList::new()));
6766
/// next.push(value)
6867
/// };

0 commit comments

Comments
 (0)