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 more
sourceimpl 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,
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
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &SourceRange<T>) -> bool
fn ne(&self, other: &SourceRange<T>) -> bool
This method tests for !=
.
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>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
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 more
sourceimpl<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(&self, source: &dyn SourceTextInfoProvider<'a>) -> &'a str
fn tokens_fast(&self, program: &dyn RootNode<'a>) -> &'a [TokenAndSpan]
fn leading_comments_fast(
&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(
&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(
&self,
program: &dyn RootNode<'a>
) -> Option<&'a TokenAndSpan>
fn next_token_fast(
&self,
program: &dyn RootNode<'a>
) -> Option<&'a TokenAndSpan>
fn previous_tokens_fast(&self, program: &dyn RootNode<'a>) -> &'a [TokenAndSpan]
fn next_tokens_fast(&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 T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
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 Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Q where
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.
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<T> Pointable for T
impl<T> Pointable for T
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more