Struct CustomArg

Source
pub struct CustomArg<T>(pub T);
Expand description

Allows a type to implement CustomArgFromMeta, a simplified version of TryFromMeta.

Tuple Fields§

§0: T

Trait Implementations§

Source§

impl<T> Concat for CustomArg<T>

Source§

const NO_DUPLICATES: bool = true

Determines whether a duplicate is allowed or if an error should be thrown.
This logic is handled in the implementation for ArgResult.
Typically only true for primitive types.
Source§

fn concat(&mut self, other: Self)

Combines an argument.
Source§

impl<T: Debug> Debug for CustomArg<T>

Source§

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

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

impl<T: Default> Default for CustomArg<T>

Source§

fn default() -> Self

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

impl<V: SynVersion, T: CustomArgFromMeta<V>> TryFromMeta<V> for CustomArg<T>

Source§

type InitialType = CustomArg<T>

This is the initial type and will be converted to Self in the validate function.
For most types this is typically Self but for lists this is a builder.
Source§

type Metadata = <V as SynVersion>::ArgMeta

The metadata of an argument or an attribute.
Source§

fn try_from_meta(meta: Self::Metadata) -> ArgResult<Self::InitialType>

Looks for values & errors in the metadata.
The returned result is added to the argument’s state using the concat method on ArgResult which in turn will call the initial type’s Concat implementation if found.
Source§

fn validate( state: ArgResult<Self::InitialType>, arg_name: &'static str, ) -> Result<Self, Vec<Error>>

Converts the initial type to Self or returns found errors.
If the argument is required it should return a missing error.
Wrapper types such as Option can overwrite this.

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

impl<T> UnwindSafe for CustomArg<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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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>,

Source§

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.