Struct deno_ast::SourceRange
source · pub struct SourceRange<T = SourcePos>where
T: Into<SourcePos> + Clone + Copy,{
pub start: T,
pub end: SourcePos,
}Fields§
§start: T§end: SourcePosImplementations§
source§impl SourceRange<SourcePos>
impl SourceRange<SourcePos>
sourcepub fn as_byte_range(&self, source_start: StartSourcePos) -> Range<usize>
pub fn as_byte_range(&self, source_start: StartSourcePos) -> Range<usize>
Gets the relative byte range based on the source text’s start position.
sourcepub fn unsafely_from_span(span: Span) -> SourceRange<SourcePos>
pub fn unsafely_from_span(span: Span) -> SourceRange<SourcePos>
Do not use this except when receiving an swc span
from swc and needing to convert it to a source position.
Generally, prefer using the .range() method.
source§impl SourceRange<StartSourcePos>
impl SourceRange<StartSourcePos>
sourcepub fn as_byte_range(&self) -> Range<usize>
pub fn as_byte_range(&self) -> Range<usize>
Gets the relative byte range based on the source text’s start position.
Trait Implementations§
source§impl<T> Clone for SourceRange<T>where
T: Clone + Into<SourcePos> + Copy,
impl<T> Clone for SourceRange<T>where T: Clone + Into<SourcePos> + Copy,
source§fn clone(&self) -> SourceRange<T>
fn clone(&self) -> SourceRange<T>
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 moresource§impl<T> Ord for SourceRange<T>where
T: Ord + Into<SourcePos> + Clone + Copy,
impl<T> Ord for SourceRange<T>where T: Ord + Into<SourcePos> + Clone + Copy,
source§fn cmp(&self, other: &SourceRange<T>) -> Ordering
fn cmp(&self, other: &SourceRange<T>) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere Self: Sized,
Compares and returns the maximum of two values. Read more
source§impl<T> PartialEq<SourceRange<T>> for SourceRange<T>where
T: PartialEq<T> + Into<SourcePos> + Clone + Copy,
impl<T> PartialEq<SourceRange<T>> for SourceRange<T>where T: PartialEq<T> + Into<SourcePos> + Clone + Copy,
source§fn eq(&self, other: &SourceRange<T>) -> bool
fn eq(&self, other: &SourceRange<T>) -> bool
This method tests for
self and other values to be equal, and is used
by ==.source§impl<T> PartialOrd<SourceRange<T>> for SourceRange<T>where
T: PartialOrd<T> + Into<SourcePos> + Clone + Copy,
impl<T> PartialOrd<SourceRange<T>> for SourceRange<T>where T: PartialOrd<T> + Into<SourcePos> + Clone + Copy,
source§fn partial_cmp(&self, other: &SourceRange<T>) -> Option<Ordering>
fn partial_cmp(&self, other: &SourceRange<T>) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self and other) and is used by the <=
operator. Read moresource§impl<T> SourceRanged for SourceRange<T>where
T: Into<SourcePos> + Clone + Copy,
impl<T> SourceRanged for SourceRange<T>where T: Into<SourcePos> + Clone + Copy,
fn start(&self) -> SourcePos
fn end(&self) -> SourcePos
fn range(&self) -> SourceRange<SourcePos>
fn byte_width(&self) -> usize
fn start_line_fast<'a, P>(&self, source: P) -> usizewhere P: SourceTextInfoProvider<'a>,
fn end_line_fast<'a, P>(&self, source: P) -> usizewhere P: SourceTextInfoProvider<'a>,
fn start_column_fast<'a, P>(&self, source: P) -> usizewhere P: SourceTextInfoProvider<'a>,
fn end_column_fast<'a, P>(&self, source: P) -> usizewhere P: SourceTextInfoProvider<'a>,
fn column_at_pos<'a, P>(&self, source: P, pos: SourcePos) -> usizewhere P: SourceTextInfoProvider<'a>,
fn char_width_fast<'a, P>(&self, source: P) -> usizewhere P: SourceTextInfoProvider<'a>,
fn text_fast<'a, P>(&self, source: P) -> &'a strwhere P: SourceTextInfoProvider<'a>,
fn tokens_fast<'a>(&self, program: impl RootNode<'a>) -> &'a [TokenAndSpan]
fn leading_comments_fast<'a>( &self, program: impl RootNode<'a> ) -> CommentsIterator<'a> ⓘ
fn trailing_comments_fast<'a>( &self, program: impl RootNode<'a> ) -> CommentsIterator<'a> ⓘ
fn previous_token_fast<'a>( &self, program: impl RootNode<'a> ) -> Option<&'a TokenAndSpan>
fn next_token_fast<'a>( &self, program: impl RootNode<'a> ) -> Option<&'a TokenAndSpan>
fn previous_tokens_fast<'a>( &self, program: impl RootNode<'a> ) -> &'a [TokenAndSpan]
fn next_tokens_fast<'a>(&self, program: impl RootNode<'a>) -> &'a [TokenAndSpan]
impl<T> Copy for SourceRange<T>where T: Copy + Into<SourcePos> + Clone,
impl<T> Eq for SourceRange<T>where T: Eq + Into<SourcePos> + Clone + Copy,
impl<T> StructuralEq for SourceRange<T>where T: Into<SourcePos> + Clone + Copy,
impl<T> StructuralPartialEq for SourceRange<T>where T: Into<SourcePos> + Clone + Copy,
Auto Trait Implementations§
impl<T> RefUnwindSafe for SourceRange<T>where T: RefUnwindSafe,
impl<T> Send for SourceRange<T>where T: Send,
impl<T> Sync for SourceRange<T>where T: Sync,
impl<T> Unpin for SourceRange<T>where T: Unpin,
impl<T> UnwindSafe for SourceRange<T>where T: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.