mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-29 10:13:54 +00:00
Document PartialEq impl for OnceLock
This commit is contained in:
parent
814df6e50e
commit
c18bab3fe6
@ -634,6 +634,26 @@ impl<T> From<T> for OnceLock<T> {
|
||||
|
||||
#[stable(feature = "once_cell", since = "1.70.0")]
|
||||
impl<T: PartialEq> PartialEq for OnceLock<T> {
|
||||
/// Equality for two `OnceLock`s.
|
||||
///
|
||||
/// Two `OnceLock`s are equal if they either both contain values and their
|
||||
/// values are equal, or if neither contains a value.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// use std::sync::OnceLock;
|
||||
///
|
||||
/// let five = OnceLock::new();
|
||||
/// five.set(5).unwrap();
|
||||
///
|
||||
/// let also_five = OnceLock::new();
|
||||
/// also_five.set(5).unwrap();
|
||||
///
|
||||
/// assert!(five == also_five);
|
||||
///
|
||||
/// assert!(OnceLock::<u32>::new() == OnceLock::<u32>::new());
|
||||
/// ```
|
||||
#[inline]
|
||||
fn eq(&self, other: &OnceLock<T>) -> bool {
|
||||
self.get() == other.get()
|
||||
|
Loading…
Reference in New Issue
Block a user