[][src]Struct amplify_derive_helpers::SingularAttr

pub struct SingularAttr {
    pub name: Ident,
    pub value: Option<ArgValue>,
}

Structure describing a procedural macro attribute with an optional value. The means that if one has something like #[name1], #[name2 = "value"], #[name3 = ::std::path::PathBuf)] than name1, name2 = "value", and name3 = ::std::path::PathBuf are three different attributes which can be parsed and represented by the SingularAttr structure.

NB: For #[attr(arg1, arg2 = value)] style of proc macros use ParametrizedAttr structure. If you need to support both use Attr enum.

Internally the structure is composed of the name and value fields, where name is always a Ident (corresponding name1, name2, name3 from the sample above) and value is an optional literal [Lit], with corresponding cases of None, Some([AttrArgValue::Lit](Lit::Str([LitStr]))), and Some([AttrArgValue::Type](Type::Path(Path))).

Fields

name: Ident

Optional attribute argument path part; for instance in #[my(name = value)] or in #[name = value] this is a name part

value: Option<ArgValue>

Optional attribute argument value part; for instance in #[name = value] this is a value part

Implementations

impl SingularAttr[src]

pub fn with_name(name: Ident) -> Self[src]

pub fn with_named_literal(name: Ident, lit: Lit) -> Self[src]

pub fn with_attribute(attr: &Attribute) -> Result<Self, Error>[src]

pub fn value(&self) -> Result<ArgValue, Error>[src]

pub fn literal_value(&self) -> Result<Lit, Error>[src]

pub fn type_value(&self) -> Result<Type, Error>[src]

pub fn merge(&mut self, other: Self) -> Result<(), Error>[src]

pub fn merged(mut self: Self, other: Self) -> Result<Self, Error>[src]

pub fn enrich(&mut self, attr: &Attribute) -> Result<(), Error>[src]

pub fn enriched(mut self: Self, attr: &Attribute) -> Result<Self, Error>[src]

pub fn check<T>(&self, _req: ValueReq<T>) -> Result<(), Error> where
    T: Clone + Eq + PartialEq + Hash + Debug
[src]

pub fn checked<T>(self, req: ValueReq<T>) -> Result<Self, Error> where
    T: Clone + Eq + PartialEq + Hash + Debug
[src]

Trait Implementations

impl Clone for SingularAttr[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.