pub(crate) struct TokenFmt<T: Keyword> {
kwd: T,
min_args: Option<usize>,
max_args: Option<usize>,
required: bool,
may_repeat: bool,
obj: ObjKind,
}
Expand description
A set of restrictions to place on Items for a single keyword.
These are built by the TokenFmtBuilder API.
Fields§
§kwd: T
Which keyword is being restricted?
min_args: Option<usize>
If present, a lower bound on how many arguments may be present.
max_args: Option<usize>
If present, an upper bound on how many arguments may be present.
required: bool
If true, then at least one of this Item must appear.
may_repeat: bool
If false, then no more than one this Item may appear.
obj: ObjKind
May this Item have an object? Must it?
Implementations§
Source§impl<T: Keyword> TokenFmt<T>
impl<T: Keyword> TokenFmt<T>
Sourcefn item_matches_args(&self, item: &Item<'_, T>) -> Result<()>
fn item_matches_args(&self, item: &Item<'_, T>) -> Result<()>
Check whether a single Item matches this TokenFmt rule, with respect to its number of arguments.
Sourcefn item_matches_obj(&self, item: &Item<'_, T>) -> Result<()>
fn item_matches_obj(&self, item: &Item<'_, T>) -> Result<()>
Check whether a single Item matches a TokenFmt rule, with respect to its object’s presence and type.
Sourcepub(crate) fn check_item(&self, item: &Item<'_, T>) -> Result<()>
pub(crate) fn check_item(&self, item: &Item<'_, T>) -> Result<()>
Check whether a single item has the right number of arguments and object.
Sourcepub(crate) fn check_multiplicity(&self, items: &[Item<'_, T>]) -> Result<()>
pub(crate) fn check_multiplicity(&self, items: &[Item<'_, T>]) -> Result<()>
Check whether this kind of item may appear this many times.
Trait Implementations§
Source§impl<T: Keyword> From<TokenFmtBuilder<T>> for TokenFmt<T>
impl<T: Keyword> From<TokenFmtBuilder<T>> for TokenFmt<T>
Source§fn from(builder: TokenFmtBuilder<T>) -> Self
fn from(builder: TokenFmtBuilder<T>) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl<T> Freeze for TokenFmt<T>where
T: Freeze,
impl<T> RefUnwindSafe for TokenFmt<T>where
T: RefUnwindSafe,
impl<T> Send for TokenFmt<T>where
T: Send,
impl<T> Sync for TokenFmt<T>where
T: Sync,
impl<T> Unpin for TokenFmt<T>where
T: Unpin,
impl<T> UnwindSafe for TokenFmt<T>where
T: UnwindSafe,
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Converts
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
, which can then be
downcast
into Box<dyn ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Converts
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
, which can then be further
downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Converts
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Converts
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSend for T
impl<T> DowncastSend for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more