Struct spl_token_2022::pod::PodCOption

source ·
#[repr(C, packed(1))]
pub struct PodCOption<T>
where T: Pod + Default,
{ /* private fields */ }
Expand description

COption stored as a Pod type

Implementations§

source§

impl<T> PodCOption<T>
where T: Pod + Default,

source

pub const NONE: [u8; 4] = _

Represents that no value is stored in the option, like Option::None

source

pub const SOME: [u8; 4] = _

Represents that some value is stored in the option, like Option::Some(v)

source

pub fn none() -> Self

Create a PodCOption equivalent of Option::None

This could be made const by using std::mem::zeroed, but that would require unsafe code, which is prohibited at the crate level.

source

pub const fn some(value: T) -> Self

Create a PodCOption equivalent of Option::Some(value)

source

pub fn unwrap_or(self, default: T) -> T

Get the underlying value or another provided value if it isn’t set, equivalent of Option::unwrap_or

source

pub fn is_some(&self) -> bool

Checks to see if a value is set, equivalent of Option::is_some

source

pub fn is_none(&self) -> bool

Checks to see if no value is set, equivalent of Option::is_none

source

pub fn ok_or<E>(self, error: E) -> Result<T, E>

Converts the option into a Result, similar to Option::ok_or

Trait Implementations§

source§

impl<T> Clone for PodCOption<T>
where T: Pod + Default + Clone + Copy,

source§

fn clone(&self) -> PodCOption<T>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<T> Debug for PodCOption<T>
where T: Pod + Default + Debug + Copy,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<T> Default for PodCOption<T>
where T: Pod + Default + Default,

source§

fn default() -> PodCOption<T>

Returns the “default value” for a type. Read more
source§

impl<T: Pod + Default> From<COption<T>> for PodCOption<T>

source§

fn from(opt: COption<T>) -> Self

Converts to this type from the input type.
source§

impl<T> PartialEq for PodCOption<T>
where T: Pod + Default + PartialEq + Copy,

source§

fn eq(&self, other: &PodCOption<T>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl TryFrom<PodCOption<Pubkey>> for OptionalNonZeroPubkey

§

type Error = ProgramError

The type returned in the event of a conversion error.
source§

fn try_from(p: PodCOption<Pubkey>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<T> Zeroable for PodCOption<T>
where T: Pod + Default + Zeroable,

source§

fn zeroed() -> Self

source§

impl<T> Copy for PodCOption<T>
where T: Pod + Default + Copy,

source§

impl<T> Pod for PodCOption<T>
where T: Pod + Default + Pod,

source§

impl<T> StructuralPartialEq for PodCOption<T>
where T: Pod + Default,

Auto Trait Implementations§

§

impl<T> Freeze for PodCOption<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for PodCOption<T>
where T: RefUnwindSafe,

§

impl<T> Send for PodCOption<T>
where T: Send,

§

impl<T> Sync for PodCOption<T>
where T: Sync,

§

impl<T> Unpin for PodCOption<T>
where T: Unpin,

§

impl<T> UnwindSafe for PodCOption<T>
where T: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CheckedBitPattern for T
where T: AnyBitPattern,

§

type Bits = T

Self must have the same layout as the specified Bits except for the possible invalid bit patterns being checked during is_valid_bit_pattern.
source§

fn is_valid_bit_pattern(_bits: &T) -> bool

If this function returns true, then it must be valid to reinterpret bits as &Self.
source§

impl<T> CloneToUninit for T
where T: Copy,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> AnyBitPattern for T
where T: Pod,

source§

impl<T> NoUninit for T
where T: Pod,