pub struct TokenFmtBuilder<T: Keyword>(TokenFmt<T>);
Expand description
Represents a TokenFmt under construction.
To construct a rule, create this type with Keyword::rule(), then call method on it to set its fields, and then pass it to SectionRules::add().
§Example
// There must be exactly one "ROUTER" entry, with 5 or more arguments.
section_rules.add(D.rule().required().args(5..));
TODO: I’d rather have this be pub(crate), but I haven’t figured out how to make that work. There are complicated cascading side-effects.
Tuple Fields§
§0: TokenFmt<T>
Implementations§
Source§impl<T: Keyword> TokenFmtBuilder<T>
impl<T: Keyword> TokenFmtBuilder<T>
Sourcepub(crate) fn new(t: T) -> Self
pub(crate) fn new(t: T) -> Self
Make a new TokenFmtBuilder with default behavior.
(By default, all arguments are allowed, the Item may appear 0 or 1 times, and it may not take an object.)
Sourcepub(crate) fn required(self) -> Self
pub(crate) fn required(self) -> Self
Indicate that this Item is required.
By default, no item is required.
Sourcepub(crate) fn may_repeat(self) -> Self
pub(crate) fn may_repeat(self) -> Self
Indicate that this Item may appear more than once.
By default, items may not repeat.
Sourcepub(crate) fn no_args(self) -> Self
pub(crate) fn no_args(self) -> Self
Indicate that this Item takes no arguments.
By default, items may take any number of arguments.
Sourcepub(crate) fn args<R>(self, r: R) -> Selfwhere
R: RangeBounds<usize>,
pub(crate) fn args<R>(self, r: R) -> Selfwhere
R: RangeBounds<usize>,
Indicate that this item takes a certain number of arguments.
The number of arguments is provided as a range, like 5..
.
Sourcepub(crate) fn obj_optional(self) -> Self
pub(crate) fn obj_optional(self) -> Self
Indicate that this token takes an optional object.
By default, objects are not allowed.
Sourcepub(crate) fn obj_required(self) -> Self
pub(crate) fn obj_required(self) -> Self
Indicate that this token takes an required object.
By default, objects are not allowed.
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
Auto Trait Implementations§
impl<T> Freeze for TokenFmtBuilder<T>where
T: Freeze,
impl<T> RefUnwindSafe for TokenFmtBuilder<T>where
T: RefUnwindSafe,
impl<T> Send for TokenFmtBuilder<T>where
T: Send,
impl<T> Sync for TokenFmtBuilder<T>where
T: Sync,
impl<T> Unpin for TokenFmtBuilder<T>where
T: Unpin,
impl<T> UnwindSafe for TokenFmtBuilder<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
§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>
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>
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)
&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)
&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>
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>
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