pub trait SourceContent {
// Required methods
fn iter(&self) -> Box<CharIter<'_>>;
fn iter_from(&self, offset: usize) -> Box<CharIter<'_>>;
fn extract(&self, begin: usize, end: usize) -> String;
fn extract_iter(&self, begin: usize, end: usize) -> Box<CharIter<'_>>;
fn bytes(&self) -> &[u8] ⓘ;
fn lines(&self) -> &[usize];
}
Required Methods§
Sourcefn iter(&self) -> Box<CharIter<'_>>
fn iter(&self) -> Box<CharIter<'_>>
Obtain an iterator over the characters within the source file, together with their respective byte positions.
Sourcefn iter_from(&self, offset: usize) -> Box<CharIter<'_>>
fn iter_from(&self, offset: usize) -> Box<CharIter<'_>>
Obtain an iterator over the characters within the source file, starting
at the provided location offset
, together with their respective byte
positions.
Sourcefn extract(&self, begin: usize, end: usize) -> String
fn extract(&self, begin: usize, end: usize) -> String
Copy a range of the source content into a String instance owned by the caller, possibly converting the encoding such that the result is in UTF-8.
Sourcefn extract_iter(&self, begin: usize, end: usize) -> Box<CharIter<'_>>
fn extract_iter(&self, begin: usize, end: usize) -> Box<CharIter<'_>>
Obtain an iterator over an extract of the source content. This might be more efficient than copying the extract into a String.