Struct darling_core::util::Flag
[−]
[src]
pub struct Flag(_);
Marker type equivalent to Option<()>
for use in attribute parsing.
Methods
impl Flag
[src]
Methods from Deref<Target = Option<()>>
pub fn is_some(&self) -> bool
1.0.0[src]
Returns true
if the option is a Some
value.
Examples
let x: Option<u32> = Some(2); assert_eq!(x.is_some(), true); let x: Option<u32> = None; assert_eq!(x.is_some(), false);
pub fn is_none(&self) -> bool
1.0.0[src]
Returns true
if the option is a None
value.
Examples
let x: Option<u32> = Some(2); assert_eq!(x.is_none(), false); let x: Option<u32> = None; assert_eq!(x.is_none(), true);
pub fn as_ref(&self) -> Option<&T>
1.0.0[src]
Converts from Option<T>
to Option<&T>
.
Examples
Convert an Option<
String
>
into an Option<
usize
>
, preserving the original.
The map
method takes the self
argument by value, consuming the original,
so this technique uses as_ref
to first take an Option
to a reference
to the value inside the original.
let text: Option<String> = Some("Hello, world!".to_string()); // First, cast `Option<String>` to `Option<&String>` with `as_ref`, // then consume *that* with `map`, leaving `text` on the stack. let text_length: Option<usize> = text.as_ref().map(|s| s.len()); println!("still can print text: {:?}", text);
ⓘImportant traits for Iter<'a, A>pub fn iter(&self) -> Iter<T>
1.0.0[src]
Returns an iterator over the possibly contained value.
Examples
let x = Some(4); assert_eq!(x.iter().next(), Some(&4)); let x: Option<u32> = None; assert_eq!(x.iter().next(), None);
Trait Implementations
impl Debug for Flag
[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl Clone for Flag
[src]
fn clone(&self) -> Flag
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Copy for Flag
[src]
impl PartialEq for Flag
[src]
fn eq(&self, __arg_0: &Flag) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Flag) -> bool
[src]
This method tests for !=
.
impl Eq for Flag
[src]
impl Default for Flag
[src]
impl Deref for Flag
[src]
type Target = Option<()>
The resulting type after dereferencing.
fn deref(&self) -> &Self::Target
[src]
Dereferences the value.
impl FromMeta for Flag
[src]
fn from_meta(mi: &Meta) -> Result<Self>
[src]
Create an instance from a syn::Meta
by dispatching to the format-appropriate trait function. This generally should not be overridden by implementers. Read more
fn from_nested_meta(item: &NestedMeta) -> Result<Self>
[src]
fn from_word() -> Result<Self>
[src]
Create an instance from the presence of the word in the attribute with no additional options specified. Read more
fn from_list(items: &[NestedMeta]) -> Result<Self>
[src]
Create an instance from a list of nested meta items.
fn from_value(value: &Lit) -> Result<Self>
[src]
Create an instance from a literal value of either foo = "bar"
or foo("bar")
. This dispatches to the appropriate method based on the type of literal encountered, and generally should not be overridden by implementers. Read more
fn from_char(value: char) -> Result<Self>
[src]
Create an instance from a char literal in a value position.
fn from_string(value: &str) -> Result<Self>
[src]
Create an instance from a string literal in a value position.
fn from_bool(value: bool) -> Result<Self>
[src]
Create an instance from a bool literal in a value position.
impl From<Flag> for bool
[src]
impl From<bool> for Flag
[src]
impl From<Option<()>> for Flag
[src]
impl PartialEq<Option<()>> for Flag
[src]
fn eq(&self, rhs: &Option<()>) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl PartialEq<Flag> for Option<()>
[src]
fn eq(&self, rhs: &Flag) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl PartialEq<bool> for Flag
[src]
fn eq(&self, rhs: &bool) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl Not for Flag
[src]
type Output = Self
The resulting type after applying the !
operator.
fn not(self) -> Self
[src]
Performs the unary !
operation.
impl BitAnd for Flag
[src]
type Output = Self
The resulting type after applying the &
operator.
fn bitand(self, rhs: Self) -> Self
[src]
Performs the &
operation.