pub struct DefLine<I, FILE = NoFile> { /* private fields */ }Expand description
A positioned iterator
When I is a char iterator DefLine<I, FILE> provides the method
DefLine::next_pos that returns the next available positioned character as
Pos<Option<char>, FILE> by calling I::next.
Implementations§
Source§impl<I, F> DefLine<I, F>
impl<I, F> DefLine<I, F>
Sourcepub fn map_iter<J, MF: FnOnce(I) -> J>(self, f: MF) -> DefLine<J, F>
pub fn map_iter<J, MF: FnOnce(I) -> J>(self, f: MF) -> DefLine<J, F>
Applies f to the inner iterator iter of type I inside self to get a new
DefLine with f(iter) as iter.
Sourcepub fn map_iter_reset<J, MF: FnOnce(I) -> J>(self, f: MF) -> DefLine<J, F>
pub fn map_iter_reset<J, MF: FnOnce(I) -> J>(self, f: MF) -> DefLine<J, F>
Like DefLine::map_iter but also resets the position to the beginning.
Source§impl<I, F> DefLine<I, F>
impl<I, F> DefLine<I, F>
Sourcepub fn new<J: IntoIterator<IntoIter = I>>(it: J) -> Self
pub fn new<J: IntoIterator<IntoIter = I>>(it: J) -> Self
Like DefLine::new_file but with F::default() as file.
Source§impl<I, F> DefLine<I, F>
impl<I, F> DefLine<I, F>
Sourcepub fn new_file<J>(it: J, f: F) -> Selfwhere
J: IntoIterator<IntoIter = I>,
pub fn new_file<J>(it: J, f: F) -> Selfwhere
J: IntoIterator<IntoIter = I>,
Creates a new DefLine with the specified iterator and file.
Sourcepub fn next_pos(&mut self) -> Pos<Option<char>, F>
pub fn next_pos(&mut self) -> Pos<Option<char>, F>
Advances the iterator and returns the next positioned value.
When the iterator has finished the returned position follows the one that has been returned by the last character.
Sourcepub fn dig_char_cf<T, MF: FnMut(char) -> ControlFlow<T>>(
&mut self,
f: MF,
) -> Pos<Option<T>, F>
pub fn dig_char_cf<T, MF: FnMut(char) -> ControlFlow<T>>( &mut self, f: MF, ) -> Pos<Option<T>, F>
Discards characters as long as Self::next_pos returns Some(ch) and f(ch) returns ControlFlow::Continue.
When f(ch) returns ControlFlow::Break(t) then this function will return Some(t).
Sourcepub fn dig_char_until<MF: FnMut(char) -> bool>(
&mut self,
f: MF,
) -> Pos<Option<char>, F>
pub fn dig_char_until<MF: FnMut(char) -> bool>( &mut self, f: MF, ) -> Pos<Option<char>, F>
Like DefLine::dig_char_cf but discards characters as long as f returns true.
Sourcepub fn next_no_spaces(&mut self) -> Pos<Option<char>, F>
pub fn next_no_spaces(&mut self) -> Pos<Option<char>, F>
Gets the first not-whitespace character.
Removes any whitespace according to
predicates::is_whitespace.
Sourcepub fn next_nl_no_spaces(&mut self) -> Pos<Option<char>, F>
pub fn next_nl_no_spaces(&mut self) -> Pos<Option<char>, F>
As Self::next_no_spaces but threats the \n character as not whitespace.
Sourcepub fn append_delim_cf<V: Appender<K>, K, Z, MF: FnMut(char) -> ControlFlow<Z, K>>(
&mut self,
f: MF,
) -> (Pos<V, F>, Pos<Option<Z>, F>)
pub fn append_delim_cf<V: Appender<K>, K, Z, MF: FnMut(char) -> ControlFlow<Z, K>>( &mut self, f: MF, ) -> (Pos<V, F>, Pos<Option<Z>, F>)
Appends characters to an accumulator.
Every time Self::next_pos returns Some(ch) and f(ch) returns
ControlFlow::Continue(k) then k is pushed into an accumulator of type V.
When f(ch) returns instead ControlFlow::Break(z) then both Some(z) and the accumulator are
returned.
Notice that, unlike Self::append_cf, ch will always be discarded.
Sourcepub fn append_delim_until<V: Appender<char>, MF: FnMut(char) -> bool>(
&mut self,
f: MF,
) -> (Pos<V, F>, Pos<Option<char>, F>)
pub fn append_delim_until<V: Appender<char>, MF: FnMut(char) -> bool>( &mut self, f: MF, ) -> (Pos<V, F>, Pos<Option<char>, F>)
Like DefLine::append_delim_cf but appends characters as long as f returns true.
Sourcepub fn append_delim_trim_cf<V: AppenderExt<K>, K, Z, SP: FnMut(char) -> bool, CF: FnMut(char) -> ControlFlow<Z, K>>(
&mut self,
sp: SP,
cf: CF,
) -> (Pos<V, F>, Pos<Option<Z>, F>)
pub fn append_delim_trim_cf<V: AppenderExt<K>, K, Z, SP: FnMut(char) -> bool, CF: FnMut(char) -> ControlFlow<Z, K>>( &mut self, sp: SP, cf: CF, ) -> (Pos<V, F>, Pos<Option<Z>, F>)
Removes leading and trailing characters.
Every character returned by DefLine::next_pos can be considered a space or a nonspace
character depending on whether sp returns true or false. Until function cf returns
ControlFlow::Continue retrieved characters are stores in a container of type V and when
cf returns ControlFlow::Break then leading and trailing spaces are removed from the
returned container.
If the returned container is not empty then the returned position is exactly the position of the first nonspace appended character, otherwise it is the position of the first character that terminated the accumulation.
Sourcepub fn append_delim_trim_until<V: AppenderExt<char>, SP: FnMut(char) -> bool, CF: FnMut(char) -> bool>(
&mut self,
sp: SP,
cf: CF,
) -> (Pos<V, F>, Pos<Option<char>, F>)
pub fn append_delim_trim_until<V: AppenderExt<char>, SP: FnMut(char) -> bool, CF: FnMut(char) -> bool>( &mut self, sp: SP, cf: CF, ) -> (Pos<V, F>, Pos<Option<char>, F>)
Like Self::append_delim_trim_cf but continue appending characters as long as cf
returns true.
Sourcepub fn get_line<V: Appender<char>>(&mut self) -> Pos<V, F>
pub fn get_line<V: Appender<char>>(&mut self) -> Pos<V, F>
Retrieves a line.
A line is a sequence of characters terminated by a \n character or up to the end of the
iterator. Notice that the eventual \n character is discarded and not added to the
returned line.
Sourcepub fn get_line_trim<V: AppenderExt<char>>(&mut self) -> Pos<V, F>
pub fn get_line_trim<V: AppenderExt<char>>(&mut self) -> Pos<V, F>
Gets a line and removes leading and trailing whitespaces.
See also DefLine::append_delim_trim_cf and predicate::is_whitespace for the used definition of
whitespace.
Source§impl<I, F> DefLine<Peekable<I>, F>
impl<I, F> DefLine<Peekable<I>, F>
Sourcepub fn peek_pos(&mut self) -> Pos<Option<char>, F>
pub fn peek_pos(&mut self) -> Pos<Option<char>, F>
Like DefLine::next_pos but doesn’t remove the character from the underlying iterator.
Sourcepub fn dig_peek_cf<T, MF: FnMut(char) -> ControlFlow<T>>(
&mut self,
f: MF,
) -> Pos<Option<T>, F>
pub fn dig_peek_cf<T, MF: FnMut(char) -> ControlFlow<T>>( &mut self, f: MF, ) -> Pos<Option<T>, F>
Like DefLine::dig_char_cf but when f(ch) returns ControlFlow::Break
then ch is not removed from the underlying iterator.
Sourcepub fn dig_peek_until<MF: FnMut(char) -> bool>(
&mut self,
f: MF,
) -> Pos<Option<char>, F>
pub fn dig_peek_until<MF: FnMut(char) -> bool>( &mut self, f: MF, ) -> Pos<Option<char>, F>
Like DefLine::dig_char_until but when f(ch) returns false then ch is not removed from
the underlying iterator.
Sourcepub fn append_cf<V: Appender<K>, K, MF: FnMut(char) -> ControlFlow<(), K>>(
&mut self,
f: MF,
) -> Pos<V, F>
pub fn append_cf<V: Appender<K>, K, MF: FnMut(char) -> ControlFlow<(), K>>( &mut self, f: MF, ) -> Pos<V, F>
Appends characters to an accumulator.
Every time DefLine::peek_pos returns Some(ch) and f(ch) returns
ControlFlow::Continue(k) then ch is discarded and k is pushed into an accumulator of type V.
When f(ch) returns instead ControlFlow::Break then ch is not discarded and the used
accumulator is returned.
Sourcepub fn append_until<V: Appender<char>, MF: FnMut(char) -> bool>(
&mut self,
f: MF,
) -> Pos<V, F>
pub fn append_until<V: Appender<char>, MF: FnMut(char) -> bool>( &mut self, f: MF, ) -> Pos<V, F>
Like DefLine::append_cf but appends characters as long as f returns true.
Moreover, when f(ch) returns true then ch is not discarded from the unerlying
iterator.
Sourcepub fn append_trim_cf<V: AppenderExt<K>, K, SP: FnMut(char) -> bool, CF: FnMut(char) -> ControlFlow<(), K>>(
&mut self,
sp: SP,
cf: CF,
) -> Pos<V, F>
pub fn append_trim_cf<V: AppenderExt<K>, K, SP: FnMut(char) -> bool, CF: FnMut(char) -> ControlFlow<(), K>>( &mut self, sp: SP, cf: CF, ) -> Pos<V, F>
Removes leading and trailing characters.
Every character returned by DefLine::peek_pos can be considered a space or a nonspace
character depending on whether sp returns true or false. Until function cf returns
ControlFlow::Continue retrieved characters are stores in a container of type V and when
cf returns ControlFlow::Break then leading and trailing spaces are removed from the
returned container.
If the returned container is not empty then the returned position is exactly the position of the first nonspace appended character, otherwise it is the position of the first character that terminated the accumulation.
Sourcepub fn trim_spaces_until<V: AppenderExt<char>, CF: FnMut(char) -> bool>(
&mut self,
f: CF,
) -> Pos<V, F>
pub fn trim_spaces_until<V: AppenderExt<char>, CF: FnMut(char) -> bool>( &mut self, f: CF, ) -> Pos<V, F>
Removes leading and trailing whitespaces.
See also DefLine::append_trim_cf and predicates::is_whitespace for the used definition of
whitespace.
Sourcepub fn get_ident<V: Appender<char>>(&mut self) -> Pos<V, F>
pub fn get_ident<V: Appender<char>>(&mut self) -> Pos<V, F>
Parse an identifier by dircarding leading whitespaces and without changing line.
Gets an identifier defined as a contiguous sequence of alphabetic characters as defined in
predicates::is_alphabetic.
Sourcepub fn get_num_nonl(&mut self) -> Pos<Option<u32>, F>
pub fn get_num_nonl(&mut self) -> Pos<Option<u32>, F>
Parses a decimal number and removes leading and trailing spaces in the same line.
Sourcepub fn peek_spaces(&mut self) -> Pos<Option<char>, F>
pub fn peek_spaces(&mut self) -> Pos<Option<char>, F>
Peeks character by discarding whitespaces and newline characters.
Removes any whitespace according to
predicates::is_whitespace.
Sourcepub fn peek_spaces_nonl(&mut self) -> Pos<Option<char>, F>
pub fn peek_spaces_nonl(&mut self) -> Pos<Option<char>, F>
Peeks character by whitespaces but not newline characters.