Enum cursive_core::utils::span::IndexedCow
source · Expand description
A span of text that can be either owned, or indexed in another String.
Variants§
Implementations§
source§impl IndexedCow
impl IndexedCow
sourcepub fn as_borrowed(&self) -> Option<(usize, usize)>
pub fn as_borrowed(&self) -> Option<(usize, usize)>
Return the (start, end)
indexes if self
is IndexedCow::Borrowed
.
sourcepub fn as_owned(&self) -> Option<&str>
pub fn as_owned(&self) -> Option<&str>
Returns the embedded text content if self
is IndexedCow::Owned
.
sourcepub fn from_str(value: &str, source: &str) -> Self
pub fn from_str(value: &str, source: &str) -> Self
Returns an indexed view of the given string.
Note: it is assumed cow
, if borrowed, is a substring of source
.
sourcepub fn from_cow(cow: Cow<'_, str>, source: &str) -> Self
pub fn from_cow(cow: Cow<'_, str>, source: &str) -> Self
Returns an indexed view of the given item.
Note: it is assumed cow
, if borrowed, is a substring of source
.
sourcepub fn offset(&mut self, offset: usize)
pub fn offset(&mut self, offset: usize)
If self
is borrowed, offset its indices by the given value.
Useful to update spans when concatenating sources. This span will now
point to text offset
further in the source.
sourcepub fn rev_offset(&mut self, offset: usize)
pub fn rev_offset(&mut self, offset: usize)
If self
is borrowed, offset its indices back by the given value.
Useful to update spans when removing a prefix from the source.
This span will now point to text offset
closer to the start of the source.
This span may become empty as a result.
Trait Implementations§
source§impl<T> AsRef<IndexedCow> for IndexedSpan<T>
impl<T> AsRef<IndexedCow> for IndexedSpan<T>
source§fn as_ref(&self) -> &IndexedCow
fn as_ref(&self) -> &IndexedCow
source§impl Clone for IndexedCow
impl Clone for IndexedCow
source§fn clone(&self) -> IndexedCow
fn clone(&self) -> IndexedCow
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more