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§
Sourceunsafe fn get_unchecked<'i>(self, source: &Source<'i>) -> Raw<'i>
Available on crate feature unsafe only.
unsafe fn get_unchecked<'i>(self, source: &Source<'i>) -> Raw<'i>
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:
spancame fromSource::lex
Failing any of those, the returned string slice may reference invalid memory or violate the invariants communicated by str type.