pub struct SourceCursor<'a> { /* private fields */ }Expand description
Implementations§
Source§impl<'a> SourceCursor<'a>
impl<'a> SourceCursor<'a>
pub const SPACE: SourceCursor<'static>
pub const TAB: SourceCursor<'static>
pub const NEWLINE: SourceCursor<'static>
pub const SEMICOLON: SourceCursor<'static>
pub const fn from(cursor: Cursor, source: &'a str) -> SourceCursor<'a>
pub const fn cursor(&self) -> Cursor
pub const fn token(&self) -> Token
pub const fn source(&self) -> &'a str
pub fn with_quotes(&self, quote_style: QuoteStyle) -> SourceCursor<'a>
pub fn with_associated_whitespace( &self, rules: AssociatedWhitespaceRules, ) -> SourceCursor<'a>
Sourcepub fn compact(&self) -> SourceCursor<'a>
pub fn compact(&self) -> SourceCursor<'a>
Returns a new SourceCursor with the should_compact flag set.
With the should_compact flag set, the cursor will format with optimised displays of:
- Numbers: Remove leading zeros (
0.8->.8), trailing zeros (1.0->1), redundant+sign - Idents/Functions/AtKeywords: Write UTF-8 instead of escape codes
- Dimensions: Same as numbers for the number part, and same as Idents for the unit part
- Whitespace: Normalize to a single space
Sourcepub fn may_compact(&self) -> bool
pub fn may_compact(&self) -> bool
Checks if calling compact().fmt(..) might produce different output than fmt(..).
This can be used to check, rather than a full allocation & display, e.g. format!("{}", sc.compact()).
- Whitespace: returns
trueif len > 1 - Ident/Function/AtKeyword/Hash: returns
trueif contains escape chars - Number: returns
trueif the number representation could be shortened - Dimension: combines number and unit checks
pub fn eq_ignore_ascii_case(&self, other: &str) -> bool
Sourcepub fn parse<A>(&self, allocator: A) -> CowStr<'a, A>
pub fn parse<A>(&self, allocator: A) -> CowStr<'a, A>
Parse the cursor’s content using any allocator that implements the Allocator trait.
Sourcepub fn parse_ascii_lower<A>(&self, allocator: A) -> CowStr<'a, A>
pub fn parse_ascii_lower<A>(&self, allocator: A) -> CowStr<'a, A>
Parse the cursor’s content to ASCII lowercase using any allocator that implements the Allocator trait.
Trait Implementations§
Source§impl<'a> Clone for SourceCursor<'a>
impl<'a> Clone for SourceCursor<'a>
Source§fn clone(&self) -> SourceCursor<'a>
fn clone(&self) -> SourceCursor<'a>
Returns a duplicate 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<'a> Debug for SourceCursor<'a>
impl<'a> Debug for SourceCursor<'a>
Source§impl<'a> Display for SourceCursor<'a>
impl<'a> Display for SourceCursor<'a>
Source§impl From<SourceCursor<'_>> for KindSet
impl From<SourceCursor<'_>> for KindSet
Source§fn from(cursor: SourceCursor<'_>) -> KindSet
fn from(cursor: SourceCursor<'_>) -> KindSet
Converts to this type from the input type.
Source§impl<'a> Hash for SourceCursor<'a>
impl<'a> Hash for SourceCursor<'a>
Source§impl<'a> Ord for SourceCursor<'a>
impl<'a> Ord for SourceCursor<'a>
Source§fn cmp(&self, other: &SourceCursor<'a>) -> Ordering
fn cmp(&self, other: &SourceCursor<'a>) -> 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 PartialEq<CommentStyle> for SourceCursor<'_>
impl PartialEq<CommentStyle> for SourceCursor<'_>
Source§impl PartialEq<Kind> for SourceCursor<'_>
impl PartialEq<Kind> for SourceCursor<'_>
Source§impl PartialEq<KindSet> for SourceCursor<'_>
impl PartialEq<KindSet> for SourceCursor<'_>
Source§impl<'a> PartialEq for SourceCursor<'a>
impl<'a> PartialEq for SourceCursor<'a>
Source§impl<'a> PartialOrd for SourceCursor<'a>
impl<'a> PartialOrd for SourceCursor<'a>
impl<'a> Copy for SourceCursor<'a>
impl<'a> Eq for SourceCursor<'a>
impl<'a> StructuralPartialEq for SourceCursor<'a>
Auto Trait Implementations§
impl<'a> Freeze for SourceCursor<'a>
impl<'a> RefUnwindSafe for SourceCursor<'a>
impl<'a> Send for SourceCursor<'a>
impl<'a> Sync for SourceCursor<'a>
impl<'a> Unpin for SourceCursor<'a>
impl<'a> UnwindSafe for SourceCursor<'a>
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