pub struct Span {
pub start: usize,
pub end: usize,
}
Expand description
A window in a char
sequence.
Although specific to harper.js
, this page may clear up any questions you have.
Fields§
§start: usize
§end: usize
Implementations§
Source§impl Span
impl Span
pub fn new(start: usize, end: usize) -> Self
pub fn new_with_len(start: usize, len: usize) -> Self
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn contains(&self, idx: usize) -> bool
pub fn overlaps_with(&self, other: Self) -> bool
Sourcepub fn try_get_content<'a>(&self, source: &'a [char]) -> Option<&'a [char]>
pub fn try_get_content<'a>(&self, source: &'a [char]) -> Option<&'a [char]>
Get the associated content. Will return None
if any aspect is
invalid.
Sourcepub fn get_content<'a>(&self, source: &'a [char]) -> &'a [char]
pub fn get_content<'a>(&self, source: &'a [char]) -> &'a [char]
Get the associated content. Will panic if any aspect is invalid.
pub fn get_content_string(&self, source: &[char]) -> String
pub fn set_len(&mut self, length: usize)
pub fn with_len(&self, length: usize) -> Self
pub fn push_by(&mut self, by: usize)
pub fn pull_by(&mut self, by: usize)
pub fn pushed_by(&self, by: usize) -> Self
pub fn pulled_by(&self, by: usize) -> Option<Self>
pub fn with_offset(&self, by: usize) -> Self
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Span
impl<'de> Deserialize<'de> for Span
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl FromIterator<Span> for Mask
impl FromIterator<Span> for Mask
Source§impl IntoIterator for Span
impl IntoIterator for Span
impl Copy for Span
impl Eq for Span
impl StructuralPartialEq for Span
Auto Trait Implementations§
impl Freeze for Span
impl RefUnwindSafe for Span
impl Send for Span
impl Sync for Span
impl Unpin for Span
impl UnwindSafe for Span
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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