pub trait SourceIndex: Debug {
    type Output: ?Sized;

    // Required method
    fn get<'src>(&self, src: &'src Source) -> Option<&'src Self::Output>;

    // Provided method
    fn index<'src>(&self, src: &'src Source) -> &'src Self::Output { ... }
}
Expand description

An index on a source code.

Required Associated Types§

source

type Output: ?Sized

Output of the indexing operation.

Required Methods§

source

fn get<'src>(&self, src: &'src Source) -> Option<&'src Self::Output>

Indexes the source code and returns None if out of bounds.

Provided Methods§

source

fn index<'src>(&self, src: &'src Source) -> &'src Self::Output

Indexes the source code and panics if out of bounds.

Implementations on Foreign Types§

source§

impl SourceIndex for RangeFrom<usize>

§

type Output = str

source§

fn get<'src>(&self, src: &'src Source) -> Option<&'src Self::Output>

source§

impl SourceIndex for RangeInclusive<usize>

§

type Output = str

source§

fn get<'src>(&self, src: &'src Source) -> Option<&'src Self::Output>

source§

impl SourceIndex for usize

§

type Output = str

source§

fn get<'src>(&self, src: &'src Source) -> Option<&'src Self::Output>

source§

impl SourceIndex for Range<usize>

§

type Output = str

source§

fn get<'src>(&self, src: &'src Source) -> Option<&'src Self::Output>

source§

impl SourceIndex for RangeToInclusive<usize>

§

type Output = str

source§

fn get<'src>(&self, src: &'src Source) -> Option<&'src Self::Output>

source§

impl SourceIndex for RangeTo<usize>

§

type Output = str

source§

fn get<'src>(&self, src: &'src Source) -> Option<&'src Self::Output>

source§

impl SourceIndex for RangeFull

§

type Output = str

source§

fn get<'src>(&self, src: &'src Source) -> Option<&'src Self::Output>

Implementors§