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: SourcePos
Implementations
sourceimpl 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.
sourceimpl 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
sourceimpl<T> Clone for SourceRange<T>where
T: Clone + Into<SourcePos> + Copy,
impl<T> Clone for SourceRange<T>where
T: Clone + Into<SourcePos> + Copy,
sourcefn clone(&self) -> SourceRange<T>
fn clone(&self) -> SourceRange<T>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresourceimpl Into<Span> for SourceRange<SourcePos>
impl Into<Span> for SourceRange<SourcePos>
sourceimpl<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,
sourcefn cmp(&self, other: &SourceRange<T>) -> Ordering
fn cmp(&self, other: &SourceRange<T>) -> Ordering
1.21.0 · sourcefn 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
1.21.0 · sourcefn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl<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,
sourcefn eq(&self, other: &SourceRange<T>) -> bool
fn eq(&self, other: &SourceRange<T>) -> bool
sourceimpl<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,
sourcefn partial_cmp(&self, other: &SourceRange<T>) -> Option<Ordering>
fn partial_cmp(&self, other: &SourceRange<T>) -> Option<Ordering>
1.0.0 · sourcefn 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 moresourceimpl<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(&self, source: &dyn SourceTextInfoProvider<'_>) -> usize
fn end_line_fast(&self, source: &dyn SourceTextInfoProvider<'_>) -> usize
fn start_column_fast(&self, source: &dyn SourceTextInfoProvider<'_>) -> usize
fn end_column_fast(&self, source: &dyn SourceTextInfoProvider<'_>) -> usize
fn column_at_pos(
&self,
source: &dyn SourceTextInfoProvider<'_>,
pos: SourcePos
) -> usize
fn char_width_fast(&self, source: &dyn SourceTextInfoProvider<'_>) -> usize
fn text_fast<'a>(&self, source: &dyn SourceTextInfoProvider<'a>) -> &'a str
fn tokens_fast<'a>(&self, program: &dyn RootNode<'a>) -> &'a [TokenAndSpan]
fn leading_comments_fast<'a>(
&self,
program: &dyn RootNode<'a>
) -> CommentsIterator<'a>ⓘNotable traits for CommentsIterator<'a>impl<'a> Iterator for CommentsIterator<'a> type Item = &'a Comment;
fn trailing_comments_fast<'a>(
&self,
program: &dyn RootNode<'a>
) -> CommentsIterator<'a>ⓘNotable traits for CommentsIterator<'a>impl<'a> Iterator for CommentsIterator<'a> type Item = &'a Comment;
fn previous_token_fast<'a>(
&self,
program: &dyn RootNode<'a>
) -> Option<&'a TokenAndSpan>
fn next_token_fast<'a>(
&self,
program: &dyn RootNode<'a>
) -> Option<&'a TokenAndSpan>
fn previous_tokens_fast<'a>(
&self,
program: &dyn RootNode<'a>
) -> &'a [TokenAndSpan]
fn next_tokens_fast<'a>(&self, program: &dyn 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
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<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,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.