[−][src]Struct amplify_derive_helpers::SingularAttr
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]
T: Clone + Eq + PartialEq + Hash + Debug,
pub fn checked<T>(self, req: ValueReq<T>) -> Result<Self, Error> where
T: Clone + Eq + PartialEq + Hash + Debug,
[src]
T: Clone + Eq + PartialEq + Hash + Debug,
Trait Implementations
impl Clone for SingularAttr
[src]
fn clone(&self) -> SingularAttr
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
Auto Trait Implementations
impl RefUnwindSafe for SingularAttr
[src]
impl !Send for SingularAttr
[src]
impl !Sync for SingularAttr
[src]
impl Unpin for SingularAttr
[src]
impl UnwindSafe for SingularAttr
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,