Skip to content

Commit ea1c14b

Browse files
committed
bug repro
1 parent 50141d3 commit ea1c14b

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

src/lib.rs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,28 @@ pub mod unsync {
392392
pub mod sync {
393393
// Can't use `OnceCell(imp::OnceCell) due to
394394
// https://github.com/rust-lang/rust/issues/50518
395-
pub use imp::OnceCell;
395+
// pub use imp::OnceCell;
396+
#[derive(Debug)]
397+
pub struct OnceCell<T>(::imp::OnceCell<T>);
398+
399+
impl<T> OnceCell<T> {
400+
pub const INIT: OnceCell<T> = OnceCell(::imp::OnceCell::INIT);
401+
pub fn new() -> OnceCell<T> {
402+
OnceCell(::imp::OnceCell::new())
403+
}
404+
405+
pub fn get(&self) -> Option<&T> {
406+
self.0.get()
407+
}
408+
409+
pub fn set(&self, value: T) -> Result<(), T> {
410+
self.0.set(value)
411+
}
412+
413+
pub fn get_or_init<F: FnOnce() -> T>(&self, f: F) -> &T {
414+
self.0.get_or_init(f)
415+
}
416+
}
396417

397418
/// A value which is initialized on the first access.
398419
///

0 commit comments

Comments
 (0)