solana_nullable/
nullable.rs1pub trait Nullable: PartialEq + Sized {
6 const NONE: Self;
8
9 fn is_none(&self) -> bool {
11 self == &Self::NONE
12 }
13
14 fn is_some(&self) -> bool {
16 !self.is_none()
17 }
18}
19
20macro_rules! nullable_integer {
21 ( $type:tt ) => {
22 #[doc = concat!("Implements `Nullable` for the `", stringify!($type), "` type, reserving `0` as the `NONE` value.")]
23 impl Nullable for $type {
24 const NONE: Self = 0;
25 }
26 };
27}
28
29nullable_integer!(u8);
30nullable_integer!(u16);
31nullable_integer!(u32);
32nullable_integer!(u64);
33#[cfg(not(target_arch = "bpf"))]
34nullable_integer!(u128);