File tree 1 file changed +20
-0
lines changed
1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -634,6 +634,26 @@ impl<T> From<T> for OnceLock<T> {
634
634
635
635
#[ stable( feature = "once_cell" , since = "1.70.0" ) ]
636
636
impl < T : PartialEq > PartialEq for OnceLock < T > {
637
+ /// Equality for two `OnceLock`s.
638
+ ///
639
+ /// Two `OnceLock`s are equal if they either both contain values and their
640
+ /// values are equal, or if neither contains a value.
641
+ ///
642
+ /// # Examples
643
+ ///
644
+ /// ```
645
+ /// use std::sync::OnceLock;
646
+ ///
647
+ /// let five = OnceLock::new();
648
+ /// five.set(5).unwrap();
649
+ ///
650
+ /// let also_five = OnceLock::new();
651
+ /// also_five.set(5).unwrap();
652
+ ///
653
+ /// assert!(five == also_five);
654
+ ///
655
+ /// assert!(OnceLock::<u32>::new() == OnceLock::<u32>::new());
656
+ /// ```
637
657
#[ inline]
638
658
fn eq ( & self , other : & OnceLock < T > ) -> bool {
639
659
self . get ( ) == other. get ( )
You can’t perform that action at this time.
0 commit comments