/// Return a subslice of the input pubfn get(&self, span: impl SourceIndex) -> Option<Raw<'i>> {
span.get(self)
}
/// 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: /// - `span` came from [`Source::lex`] /// /// Failing any of those, the returned string slice may reference invalid memory or violate the invariants communicated by `str` type. #[cfg(feature = "unsafe")] pubunsafefn get_unchecked(&self, span: impl SourceIndex) -> Raw<'i> { // SAFETY: Same safety guarantees are required unsafe { span.get_unchecked(self) }
}
/// Return a subslice of the input fn get_raw_str(&self, span: Span) -> Option<&'i str> { let index = span.start()..span.end(); self.input.get(index)
}
/// 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: /// - `span` came from [`Source::lex`] /// /// Failing any of those, the returned string slice may reference invalid memory or violate the invariants communicated by `str` type. #[cfg(feature = "unsafe")] unsafefn get_raw_str_unchecked(&self, span: Span) -> &'color:blue'>'i str { let index = span.start()..span.end(); // SAFETY: Same safety guarantees are required unsafe { self.input.get_unchecked(index) }
}
}
/// A slice of [`Source`] #[derive(Copy, Clone, Debug)] pubstruct Raw<'i> {
raw: &'i str,
encoding: Option<Encoding>,
span: Span,
}
/// A helper trait used for indexing operations on [`Source`] pubtrait SourceIndex: sealed::Sealed { /// Return a subslice of the input fn get<'i>(self, source: &Source<'i>) -> Option<Raw<'i>>;
/// 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: /// - `span` came from [`Source::lex`] /// /// Failing any of those, the returned string slice may reference invalid memory or violate the invariants communicated by `str` type. #[cfg(feature = "unsafe")] unsafefn get_unchecked<'i>(self, source: &Source<'i>) -> Raw<'i>;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.