pub struct DefLine<I, FILE = ()> { /* private fields */ }Expand description
A positioned iterator
When I is a char iterator DefLine<I, FILE> provides the method
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 next_pos_cf<T, MF: FnMut(char) -> ControlFlow<T>>(
&mut self,
f: MF,
) -> Pos<Option<T>, F>
pub fn next_pos_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 next_pos_until<MF: FnMut(char) -> bool>(
&mut self,
f: MF,
) -> Pos<Option<char>, F>
pub fn next_pos_until<MF: FnMut(char) -> bool>( &mut self, f: MF, ) -> Pos<Option<char>, F>
Like DefLine::next_pos_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>
Next character discarding whitespaces and newline characters.
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>
Next character discarding whitespaces but not newline characters.
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 peek_pos_cf<T, MF: FnMut(char) -> ControlFlow<T>>(
&mut self,
f: MF,
) -> Pos<Option<T>, F>
pub fn peek_pos_cf<T, MF: FnMut(char) -> ControlFlow<T>>( &mut self, f: MF, ) -> Pos<Option<T>, F>
Like DefLine::next_pos_cf but when f(ch) returns ControlFlow::Break
then ch is not removed from the underlying iterator.
sourcepub fn peek_pos_until<MF: FnMut(char) -> bool>(
&mut self,
f: MF,
) -> Pos<Option<char>, F>
pub fn peek_pos_until<MF: FnMut(char) -> bool>( &mut self, f: MF, ) -> Pos<Option<char>, F>
Like DefLine::next_pos_until but when f(ch) returns false then ch is not removed from
the underlying iterator.
sourcepub fn grab_cf<V: Appender<K>, K, MF: FnMut(char) -> ControlFlow<(), K>>(
&mut self,
f: MF,
) -> Pos<V, F>
pub fn grab_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 grab_until<V: Appender<char>, MF: FnMut(char) -> bool>(
&mut self,
f: MF,
) -> Pos<V, F>
pub fn grab_until<V: Appender<char>, MF: FnMut(char) -> bool>( &mut self, f: MF, ) -> Pos<V, F>
Like DefLine::grab_cf but appends characters as long as f returns true.
sourcepub fn cap_ht_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 cap_ht_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 cap_spaces<V: AppenderExt<char>, CF: FnMut(char) -> ControlFlow<()>>(
&mut self,
f: CF,
) -> Pos<V, F>
pub fn cap_spaces<V: AppenderExt<char>, CF: FnMut(char) -> ControlFlow<()>>( &mut self, f: CF, ) -> Pos<V, F>
Removes leading and trailing whitespaces.
See also DefLine::cap_ht_cf and predicates::is_whitespace for the used definition of whitespace.
sourcepub fn get_line_cap<V: AppenderExt<char>>(&mut self) -> Pos<V, F>
pub fn get_line_cap<V: AppenderExt<char>>(&mut self) -> Pos<V, F>
Gets a line and removes leading and trailing whitespaces.
See also DefLine::cap_ht_cf and predicate::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.
Gets an identifier defined as a contiguous sequence of alphabetic characters as defined in predicates::is_alphabetic.
sourcepub fn get_hex_num(&mut self) -> Pos<Option<u32>, F>
pub fn get_hex_num(&mut self) -> Pos<Option<u32>, F>
Parses an hexadecimal number (without the prefix).
sourcepub fn peek_no_spaces(&mut self) -> Pos<Option<char>, F>
pub fn peek_no_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_nl_no_spaces(&mut self) -> Pos<Option<char>, F>
pub fn peek_nl_no_spaces(&mut self) -> Pos<Option<char>, F>
Peeks character by whitespaces but not newline characters.