Skip to main content

solana_nullable/
nullable.rs

1/// Trait for types that can be `None`.
2///
3/// This trait is used to indicate that a type can reserve a specific value to
4/// represent `None`.
5pub trait Nullable: PartialEq + Sized {
6    /// Value that represents `None` for the type.
7    const NONE: Self;
8
9    /// Indicates whether the value is `None` or not.
10    fn is_none(&self) -> bool {
11        self == &Self::NONE
12    }
13
14    /// Indicates whether the value is a `Some` value of type `Self` or not.
15    fn is_some(&self) -> bool {
16        !self.is_none()
17    }
18}