File tree Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -392,7 +392,28 @@ pub mod unsync {
392
392
pub mod sync {
393
393
// Can't use `OnceCell(imp::OnceCell) due to
394
394
// 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
+ }
396
417
397
418
/// A value which is initialized on the first access.
398
419
///
You can’t perform that action at this time.
0 commit comments