pub struct RepeatCount(/* private fields */);Expand description
The N of a repeated(P, N) — at least one section, by construction.
A group of no sections parses nothing: repeated(P, 0) would produce an
empty Vec while consuming no input, which is not a parser anybody means to
write and reads as a typo for the unbounded form. A negative count names no
sections at all. Both are the same kind of value Separator refuses one
field over — a number the runtime would have to invent a meaning for — and
they are refused the same way, by the one constructor, rather than by a
validate arm the next construction site can forget.
The upper bound is the plan’s: crate::plan::SectionItemNode stores the
count as a u32, because the plan is a flat &'static repr the runtime
reads without allocating. A count that does not fit is refused here, where
the source span is still in hand, rather than truncated there.
Implementations§
Source§impl RepeatCount
impl RepeatCount
Sourcepub fn new(n: i64) -> Result<Self, InvalidRepeatCount>
pub fn new(n: i64) -> Result<Self, InvalidRepeatCount>
The only constructor. Refuses a count that names no sections.
§Errors
InvalidRepeatCount for n <= 0 or n > u32::MAX.
Trait Implementations§
Source§impl Clone for RepeatCount
impl Clone for RepeatCount
Source§fn clone(&self) -> RepeatCount
fn clone(&self) -> RepeatCount
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more