macro_rules! impl_slice_range {
    ( $fragment_type:ty, $range_type:ty, $can_return_self:expr ) => { ... };
}
Expand description

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’s fragment type
  • $range_type - The range type to be use with slice().
  • $can_return_self - A bool-returning lambda telling whether we can avoid creating a new LocatedSpan. If unsure, use |_| false.

§Example of use

NB: This example is an extract from the nom_locate source code.

#[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}
    }
}