[go: up one dir, main page]

SourceIndex

Trait SourceIndex 

Source
pub trait SourceIndex: Sealed {
    // Required methods
    fn get<'i>(self, source: &Source<'i>) -> Option<Raw<'i>>;
    unsafe fn get_unchecked<'i>(self, source: &Source<'i>) -> Raw<'i>;
}
Expand description

A helper trait used for indexing operations on Source

Required Methods§

Source

fn get<'i>(self, source: &Source<'i>) -> Option<Raw<'i>>

Return a subslice of the input

Source

unsafe fn get_unchecked<'i>(self, source: &Source<'i>) -> Raw<'i>

Available on crate feature unsafe only.

Return an unchecked subslice of the input

§Safety

Callers of this function are responsible that these preconditions are satisfied:

  • The starting index must not exceed the ending index;
  • Indexes must be within bounds of the original slice;
  • Indexes must lie on UTF-8 sequence boundaries.

Or one of:

Failing any of those, the returned string slice may reference invalid memory or violate the invariants communicated by str type.

Implementors§