pub struct DynBoxSliceCopied<Output, T>where
Output: Tuple,
T: Copy,{ /* private fields */ }
Expand description
A Box<dyn Parser>
wrapper for iterators of std::iter::Copied<std::slice::Iter>
.
This can take any parser with Output of Output
.
Once you wrap the parser with this, you can only use input iterator of std::iter::Copied<std::slice::Iter>
.
Default
is implemented, with always-panic-parser
use rusty_parser as rp;
use rp::IntoParser;
let mut parser = rp::DynBoxSliceCopied::<(i32,), i32>::default();
// #[should_panic]
// let res = rp::parse(&parser, (&[1,2,3]).iter().copied());
parser.assign( 0..=9 );
let res = rp::parse(&parser, (&[1,2,3,4,5,6]).iter().copied());
assert_eq!( res.output.unwrap(), (1,) );
Implementations§
Source§impl<Output, T> DynBoxSliceCopied<Output, T>where
Output: Tuple,
T: Copy,
impl<Output, T> DynBoxSliceCopied<Output, T>where
Output: Tuple,
T: Copy,
pub fn new<ParserType: IntoParser>(parser: ParserType) -> Self
pub fn assign<ParserType: IntoParser>(&mut self, parser: ParserType)
Trait Implementations§
Source§impl<Output: Tuple + 'static, T: Copy + 'static> Default for DynBoxSliceCopied<Output, T>
default to dummy parser that always panic
impl<Output: Tuple + 'static, T: Copy + 'static> Default for DynBoxSliceCopied<Output, T>
default to dummy parser that always panic
Source§impl<Output, T> Deref for DynBoxSliceCopied<Output, T>where
Output: Tuple,
T: Copy,
impl<Output, T> Deref for DynBoxSliceCopied<Output, T>where
Output: Tuple,
T: Copy,
Source§impl<Output, T> DerefMut for DynBoxSliceCopied<Output, T>where
Output: Tuple,
T: Copy,
impl<Output, T> DerefMut for DynBoxSliceCopied<Output, T>where
Output: Tuple,
T: Copy,
Source§impl<Output, T> IntoParser for DynBoxSliceCopied<Output, T>where
Output: Tuple,
T: Copy,
impl<Output, T> IntoParser for DynBoxSliceCopied<Output, T>where
Output: Tuple,
T: Copy,
Source§type Into = DynBoxSliceCopied<Output, T>
type Into = DynBoxSliceCopied<Output, T>
Target Parser type
Source§fn into_parser(self) -> Self::Into
fn into_parser(self) -> Self::Into
convert self to Parser Read more
Source§fn seq<RhsParser: IntoParser>(
self,
rhs: RhsParser,
) -> SeqParser<Self::Into, RhsParser::Into>where
Self: Sized,
fn seq<RhsParser: IntoParser>(
self,
rhs: RhsParser,
) -> SeqParser<Self::Into, RhsParser::Into>where
Self: Sized,
concatenate two parser Read more
Source§fn repeat<RangeTypeIncludeInteger>(
self,
range: RangeTypeIncludeInteger,
) -> RepeatParser<Self::Into, RangeTypeIncludeInteger::Into>
fn repeat<RangeTypeIncludeInteger>( self, range: RangeTypeIncludeInteger, ) -> RepeatParser<Self::Into, RangeTypeIncludeInteger::Into>
repeat parser multiple times. This tries to match as long as possible. Read more
Source§fn or<RhsParser: IntoParser>(
self,
rhs: RhsParser,
) -> OrParser<Self::Into, RhsParser::Into>where
Self: Sized,
fn or<RhsParser: IntoParser>(
self,
rhs: RhsParser,
) -> OrParser<Self::Into, RhsParser::Into>where
Self: Sized,
or combinator for two parsers Read more
Source§fn map<ClosureType>(
self,
callback: ClosureType,
) -> MapParser<Self::Into, ClosureType>where
Self: Sized,
fn map<ClosureType>(
self,
callback: ClosureType,
) -> MapParser<Self::Into, ClosureType>where
Self: Sized,
Map parser’s Output to new value. Read more
Source§fn void(self) -> VoidParser<Self::Into>where
Self: Sized,
fn void(self) -> VoidParser<Self::Into>where
Self: Sized,
Change Parser’s Output to
()
.
This internally call crate::match_pattern()
instead of crate::parse()
Read moreSource§fn optional(self) -> OptionalParser<Self::Into>where
Self: Sized,
fn optional(self) -> OptionalParser<Self::Into>where
Self: Sized,
This parser always success whether the input is matched or not. Read more
Source§fn optional_or<Output: Clone>(
self,
output: Output,
) -> OptionalOrParser<Self::Into, Output>where
Self: Sized,
fn optional_or<Output: Clone>(
self,
output: Output,
) -> OptionalOrParser<Self::Into, Output>where
Self: Sized,
This parser always success whether the input is matched or not.
If it failed, the given value will be returned. Read more
Source§fn or_else<Closure>(
self,
closure: Closure,
) -> OptionalOrElseParser<Self::Into, Closure>where
Self: Sized,
fn or_else<Closure>(
self,
closure: Closure,
) -> OptionalOrElseParser<Self::Into, Closure>where
Self: Sized,
This parser always success whether the input is matched or not.
If it failed, the given closure will be evaluated and returned. Read more
Source§fn not<RhsParser: IntoParser>(
self,
rhs: RhsParser,
) -> NotParser<Self::Into, RhsParser::Into>where
Self: Sized,
fn not<RhsParser: IntoParser>(
self,
rhs: RhsParser,
) -> NotParser<Self::Into, RhsParser::Into>where
Self: Sized,
Match for parser1 but not parser2. Read more
Source§fn output<Output: Clone>(
self,
output: Output,
) -> OutputParser<Self::Into, Output>where
Self: Sized,
fn output<Output: Clone>(
self,
output: Output,
) -> OutputParser<Self::Into, Output>where
Self: Sized,
Change Parser’s Output to (output,). Read more
Source§fn not_consume(self) -> NotConsumeParser<Self::Into>where
Self: Sized,
fn not_consume(self) -> NotConsumeParser<Self::Into>where
Self: Sized,
Parser will not consume the input iterator.
It still matches and return the output. Read more
Source§fn reduce_left<RhsParser, Reducer>(
self,
rhs: RhsParser,
reducer: Reducer,
) -> ReduceLeftParser<Self::Into, RhsParser::Into, Reducer>where
Self: Sized,
RhsParser: IntoParser,
fn reduce_left<RhsParser, Reducer>(
self,
rhs: RhsParser,
reducer: Reducer,
) -> ReduceLeftParser<Self::Into, RhsParser::Into, Reducer>where
Self: Sized,
RhsParser: IntoParser,
Reduce the output of the parser with the given reducer. Read more
Source§fn reduce_right<LhsParser, Reducer>(
self,
lhs: LhsParser,
reducer: Reducer,
) -> ReduceRightParser<LhsParser::Into, Self::Into, Reducer>where
Self: Sized,
LhsParser: IntoParser,
fn reduce_right<LhsParser, Reducer>(
self,
lhs: LhsParser,
reducer: Reducer,
) -> ReduceRightParser<LhsParser::Into, Self::Into, Reducer>where
Self: Sized,
LhsParser: IntoParser,
Reduce the output of the parser with the given reducer. Read more
Source§fn reduce_with<Init, Reducer>(
self,
init: Init,
reducer: Reducer,
) -> ReduceInitParser<Self::Into, Init, Reducer>
fn reduce_with<Init, Reducer>( self, init: Init, reducer: Reducer, ) -> ReduceInitParser<Self::Into, Init, Reducer>
Reduce the output of the parser with the given reducer. Read more
Source§fn reduce_right_with<Init, Reducer>(
self,
init: Init,
reducer: Reducer,
) -> ReduceRightInitParser<Self::Into, Init, Reducer>
fn reduce_right_with<Init, Reducer>( self, init: Init, reducer: Reducer, ) -> ReduceRightInitParser<Self::Into, Init, Reducer>
Reduce the output of the parser with the given reducer. Read more
Auto Trait Implementations§
impl<Output, T> Freeze for DynBoxSliceCopied<Output, T>
impl<Output, T> !RefUnwindSafe for DynBoxSliceCopied<Output, T>
impl<Output, T> !Send for DynBoxSliceCopied<Output, T>
impl<Output, T> !Sync for DynBoxSliceCopied<Output, T>
impl<Output, T> Unpin for DynBoxSliceCopied<Output, T>
impl<Output, T> !UnwindSafe for DynBoxSliceCopied<Output, T>
Blanket Implementations§
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