pub enum FieldStatus<T> {
None,
ParseError,
Some(T),
}
Expand description
Temporary container for storing parsing state for a single field.
Variants§
None
Field is not present or not parsed yet.
ParseError
Field was present, but had an error during parsing.
Some(T)
Field was found and successfully parsed.
Implementations§
Source§impl<T> FieldStatus<T>
impl<T> FieldStatus<T>
Sourcepub const fn as_ref(&self) -> FieldStatus<&T>
pub const fn as_ref(&self) -> FieldStatus<&T>
Converts from &FieldStatus<T>
to FieldStatus<&T>
.
Sourcepub fn and<U>(self, b: FieldStatus<U>) -> FieldStatus<U>
pub fn and<U>(self, b: FieldStatus<U>) -> FieldStatus<U>
Returns b
if the status is Some
.
Sourcepub fn and_then<U, F: FnOnce(T) -> FieldStatus<U>>(self, f: F) -> FieldStatus<U>
pub fn and_then<U, F: FnOnce(T) -> FieldStatus<U>>(self, f: F) -> FieldStatus<U>
If the status is Some
, calls f
with the wrapped value and returns the result.
Sourcepub fn map<U, F: FnOnce(T) -> U>(self, f: F) -> FieldStatus<U>
pub fn map<U, F: FnOnce(T) -> U>(self, f: F) -> FieldStatus<U>
Maps a FieldStatus<T>
to FieldStatus<U>
by applying a function to a contained value.
Sourcepub const fn is_none(&self) -> bool
pub const fn is_none(&self) -> bool
Returns true
if the field is a FieldStatus::None
value.
Sourcepub const fn is_parse_error(&self) -> bool
pub const fn is_parse_error(&self) -> bool
Returns true
if the field is a FieldStatus::ParseError
value.
Sourcepub const fn is_some(&self) -> bool
pub const fn is_some(&self) -> bool
Returns true
if the field is a FieldStatus::Some
value.
Sourcepub fn or(self, b: FieldStatus<T>) -> FieldStatus<T>
pub fn or(self, b: FieldStatus<T>) -> FieldStatus<T>
Returns the status if it contains a value, or if it is None
then returns b
.
Sourcepub fn or_else<F: FnOnce() -> FieldStatus<T>>(self, f: F) -> FieldStatus<T>
pub fn or_else<F: FnOnce() -> FieldStatus<T>>(self, f: F) -> FieldStatus<T>
Returns the status if it contains a value, or if it is None
then calls f
and returns
the result.
Sourcepub fn unwrap(self) -> T
pub fn unwrap(self) -> T
Returns the contained FieldStatus::Some
value, consuming the self
value.
§Panics
Panics if the self value equals FieldStatus::None
or FieldStatus::ParseError
.
Sourcepub fn unwrap_or(self, default: T) -> T
pub fn unwrap_or(self, default: T) -> T
Returns the contained FieldStatus::Some
value or a provided default.
Sourcepub fn unwrap_or_else<F: FnOnce() -> T>(self, f: F) -> T
pub fn unwrap_or_else<F: FnOnce() -> T>(self, f: F) -> T
Returns the contained FieldStatus::Some
value or computes it from a closure.
Sourcepub fn flatten<U>(self) -> FieldStatus<U>where
T: Into<FieldStatus<U>>,
pub fn flatten<U>(self) -> FieldStatus<U>where
T: Into<FieldStatus<U>>,
Converts from FieldStatus<impl Into<FieldStatus<T>>>
to FieldStatus<T>
.
Sourcepub fn parse_named_item(
&mut self,
name: &str,
input: ParseStream<'_>,
span: Span,
errors: &Errors,
)where
T: ParseMetaItem,
pub fn parse_named_item(
&mut self,
name: &str,
input: ParseStream<'_>,
span: Span,
errors: &Errors,
)where
T: ParseMetaItem,
Parses a named item into this status.
Sourcepub fn parse_named_item_with<F>(
&mut self,
name: &str,
input: ParseStream<'_>,
span: Span,
errors: &Errors,
func: F,
)
pub fn parse_named_item_with<F>( &mut self, name: &str, input: ParseStream<'_>, span: Span, errors: &Errors, func: F, )
Parses a named item into this status, using a custom parsing function.
Sourcepub fn parse_unnamed_item(&mut self, input: ParseStream<'_>, errors: &Errors)where
T: ParseMetaItem,
pub fn parse_unnamed_item(&mut self, input: ParseStream<'_>, errors: &Errors)where
T: ParseMetaItem,
Parses an unnamed item into this status.
Sourcepub fn parse_unnamed_item_with<F>(
&mut self,
input: ParseStream<'_>,
errors: &Errors,
func: F,
)
pub fn parse_unnamed_item_with<F>( &mut self, input: ParseStream<'_>, errors: &Errors, func: F, )
Parses an unnamed item into this status, using a custom parsing function.
Sourcepub fn into_option(self) -> Option<T>
pub fn into_option(self) -> Option<T>
Converts the status to an Option
.
Trait Implementations§
Source§impl<T: Clone> Clone for FieldStatus<T>
impl<T: Clone> Clone for FieldStatus<T>
Source§fn clone(&self) -> FieldStatus<T>
fn clone(&self) -> FieldStatus<T>
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
source
. Read more