[−][src]Macro nom5_locate::impl_slice_range
Implement nom::Slice for a specific fragment type and range type.
You'd probably better use impl_slice_ranges
,
unless you use a specific Range.
Parameters
$fragment_type
- The LocatedSpan'sfragment
type$range_type
- The range type to be use withslice()
.$can_return_self
- A bool-returning lambda telling whether we can avoid creating a newLocatedSpan
. If unsure, use|_| false
.
Example of use
NB: This example is an extract from the nom_locate source code.
ⓘThis example is not tested
#[macro_use] extern crate nom_locate; #[macro_export] macro_rules! impl_slice_ranges { ( $fragment_type:ty ) => { impl_slice_range! {$fragment_type, Range<usize>, |_| false } impl_slice_range! {$fragment_type, RangeTo<usize>, |_| false } impl_slice_range! {$fragment_type, RangeFrom<usize>, |range:&RangeFrom<usize>| range.start == 0} impl_slice_range! {$fragment_type, RangeFull, |_| true} } }