pub struct Source { /* private fields */ }Expand description
Source text addressed by UTF-16 code units, as JavaScript strings are.
Implementations§
Source§impl Source
impl Source
pub fn new(text: &str) -> Self
pub const fn len(&self) -> usize
pub const fn is_empty(&self) -> bool
pub fn units(&self) -> &[u16]
Sourcepub fn char_at(&self, index: usize) -> Option<char>
pub fn char_at(&self, index: usize) -> Option<char>
The code unit at index as a character; lone surrogates are None.
Sourcepub fn is_char(&self, index: usize, ch: char) -> bool
pub fn is_char(&self, index: usize, ch: char) -> bool
True when the unit at index is the ASCII or BMP character ch.
pub fn starts_with(&self, pattern: &str, index: usize) -> bool
Sourcepub fn slice(&self, start: usize, end: usize) -> String
pub fn slice(&self, start: usize, end: usize) -> String
source.slice(start, end), clamped like JavaScript’s.
Sourcepub fn index_of(&self, pattern: &str, from: usize) -> Option<usize>
pub fn index_of(&self, pattern: &str, from: usize) -> Option<usize>
source.indexOf(pattern, from).
Sourcepub fn code_point_text(&self, index: usize) -> String
pub fn code_point_text(&self, index: usize) -> String
String.fromCodePoint(source.codePointAt(index)): the whole character
when index starts a surrogate pair.
Trait Implementations§
impl Eq for Source
impl StructuralPartialEq for Source
Auto Trait Implementations§
impl Freeze for Source
impl RefUnwindSafe for Source
impl Send for Source
impl Sync for Source
impl Unpin for Source
impl UnsafeUnpin for Source
impl UnwindSafe for Source
Blanket Implementations§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Returns the layout of the type.