swc_common::input

Trait Input

Source
pub trait Input: Clone {
Show 15 methods // Required methods fn cur(&mut self) -> Option<char>; fn peek(&mut self) -> Option<char>; fn peek_ahead(&mut self) -> Option<char>; fn bump(&mut self); fn is_at_start(&self) -> bool; fn cur_pos(&mut self) -> BytePos; fn last_pos(&self) -> BytePos; fn slice(&mut self, start: BytePos, end: BytePos) -> &str; fn uncons_while<F>(&mut self, f: F) -> &str where F: FnMut(char) -> bool; fn find<F>(&mut self, f: F) -> Option<BytePos> where F: FnMut(char) -> bool; fn reset_to(&mut self, to: BytePos); fn is_str(&self, s: &str) -> bool; // Provided methods fn cur_as_ascii(&mut self) -> Option<u8> { ... } fn is_byte(&mut self, c: u8) -> bool { ... } fn eat_byte(&mut self, c: u8) -> bool { ... }
}

Required Methods§

Source

fn cur(&mut self) -> Option<char>

Source

fn peek(&mut self) -> Option<char>

Source

fn peek_ahead(&mut self) -> Option<char>

Source

fn bump(&mut self)

Source

fn is_at_start(&self) -> bool

Source

fn cur_pos(&mut self) -> BytePos

Source

fn last_pos(&self) -> BytePos

Source

fn slice(&mut self, start: BytePos, end: BytePos) -> &str

Source

fn uncons_while<F>(&mut self, f: F) -> &str
where F: FnMut(char) -> bool,

Takes items from stream, testing each one with predicate. returns the range of items which passed predicate.

Source

fn find<F>(&mut self, f: F) -> Option<BytePos>
where F: FnMut(char) -> bool,

This method modifies [last_pos()] and [cur_pos()].

Source

fn reset_to(&mut self, to: BytePos)

Source

fn is_str(&self, s: &str) -> bool

Implementors can override the method to make it faster.

s must be ASCII only.

Provided Methods§

Source

fn cur_as_ascii(&mut self) -> Option<u8>

Returns None if it’s end of input or current character is not an ascii character.

Source

fn is_byte(&mut self, c: u8) -> bool

Implementors can override the method to make it faster.

c must be ASCII.

Source

fn eat_byte(&mut self, c: u8) -> bool

Implementors can override the method to make it faster.

c must be ASCII.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<'a> Input for StringInput<'a>