Struct parse_js::source::SourceRange
source · pub struct SourceRange<'a> {
pub source: &'a [u8],
pub edit: Option<&'a [u8]>,
pub start: usize,
pub end: usize,
}
Expand description
A string backed by a source. Treated as a string, so contents rather than position is considered the value. It’s illegal to operate on two SourceRange values from different sources, like Add or Eq. Adding two SourceRange (Add, AddAssign, add_option, etc.) values is illegal if at least one has an edit, due to ambiguity. Performing these illegal actions may result in a panic.
Fields§
§source: &'a [u8]
§edit: Option<&'a [u8]>
§start: usize
§end: usize
Implementations§
source§impl<'a> SourceRange<'a>
impl<'a> SourceRange<'a>
pub fn get_start_of_source(&self) -> SourceRange<'a>
pub fn get_end_of_source(&self) -> SourceRange<'a>
pub fn error( self, typ: SyntaxErrorType, actual_token: Option<TokenType> ) -> SyntaxError<'a>
pub fn add_option(&self, rhs: Option<SourceRange<'a>>) -> SourceRange<'a>
pub fn with_edit(&self, edit: &'a [u8]) -> SourceRange<'a>
pub fn is_empty(&self) -> bool
pub fn is_eof(&self) -> bool
pub fn as_slice(&self) -> &[u8] ⓘ
pub fn as_str(&self) -> &str
pub fn len(&self) -> usize
pub fn extend(&mut self, other: SourceRange<'_>)
Trait Implementations§
source§impl<'a> Add<SourceRange<'a>> for SourceRange<'a>
impl<'a> Add<SourceRange<'a>> for SourceRange<'a>
source§impl<'a> AddAssign<SourceRange<'a>> for SourceRange<'a>
impl<'a> AddAssign<SourceRange<'a>> for SourceRange<'a>
source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
Performs the
+=
operation. Read moresource§impl<'a> Clone for SourceRange<'a>
impl<'a> Clone for SourceRange<'a>
source§fn clone(&self) -> SourceRange<'a>
fn clone(&self) -> SourceRange<'a>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read more