Struct ress::ManualScanner

source ·
pub struct ManualScanner<'a> {
    pub stream: Tokenizer<'a>,
    pub eof: bool,
    pub pending_new_line: bool,
    pub last_skipped_whitespace: usize,
    pub new_line_count: usize,
    /* private fields */
}

Fields§

§stream: Tokenizer<'a>§eof: bool§pending_new_line: bool§last_skipped_whitespace: usize§new_line_count: usize

Implementations§

source§

impl<'b> ManualScanner<'b>

source

pub fn new(text: &'b str) -> Self

source

pub fn skip_comments(&mut self) -> Result<(), Error>

Skip any upcoming comments to get the next valid js token

source

pub fn get_state(&self) -> ScannerState

Get a copy of the scanner’s current state

source

pub fn set_state(&mut self, state: ScannerState)

Set the scanner’s current state to the state provided

source

pub fn next_token(&mut self) -> Option<Result<Item<&'b str>, Error>>

source

pub fn next_regex( &mut self, prev_len: usize ) -> Option<Result<Item<&'b str>, Error>>

Get the next token as a regular expression. The previous token should have been / or /=,

source

pub fn string_for(&self, span: &Span) -> Option<String>

Get a string for any given span

source

pub fn str_for(&self, span: &Span) -> Option<&'b str>

Get a &str for any given span

source

pub fn position_for(&self, idx: usize) -> (usize, usize)

Get the line/column pair for any given byte index

Auto Trait Implementations§

§

impl<'a> RefUnwindSafe for ManualScanner<'a>

§

impl<'a> Send for ManualScanner<'a>

§

impl<'a> Sync for ManualScanner<'a>

§

impl<'a> Unpin for ManualScanner<'a>

§

impl<'a> UnwindSafe for ManualScanner<'a>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.