[−][src]Struct cursive::utils::span::SpannedString
A string with associated spans.
Each span has an associated attribute T
.
Implementations
impl SpannedString<Style>
[src]
pub fn plain<S>(content: S) -> SpannedString<Style> where
S: Into<String>,
[src]
S: Into<String>,
Returns a plain StyledString without any style.
You got no style, Dutch. You know that.
pub fn styled<S, T>(content: S, style: T) -> SpannedString<Style> where
S: Into<String>,
T: Into<Style>,
[src]
S: Into<String>,
T: Into<Style>,
Creates a new StyledString
using a single style for the entire text.
pub fn append_plain<S>(&mut self, text: S) where
S: Into<String>,
[src]
S: Into<String>,
Appends the given plain text to self
.
pub fn append_styled<S, T>(&mut self, text: S, style: T) where
S: Into<String>,
T: Into<Style>,
[src]
S: Into<String>,
T: Into<Style>,
Appends text
to self
, using style
.
impl SpannedString<()>
[src]
pub fn plain<S>(content: S) -> SpannedString<()> where
S: Into<String>,
[src]
S: Into<String>,
Returns a simple spanned string without any attribute.
impl<T> SpannedString<T>
[src]
pub fn new() -> SpannedString<T>
[src]
Returns an empty SpannedString
.
pub fn with_spans<S>(
source: S,
spans: Vec<IndexedSpan<T>, Global>
) -> SpannedString<T> where
S: Into<String>,
[src]
source: S,
spans: Vec<IndexedSpan<T>, Global>
) -> SpannedString<T> where
S: Into<String>,
Creates a new SpannedString
manually.
It is not recommended to use this directly.
Instead, look for methods like Markdown::parse
.
pub fn compact(&mut self)
[src]
Compacts the source to only include the spans content.
pub fn trim_end(&mut self)
[src]
Shrink the source to discard any unused suffix.
pub fn trim_start(&mut self)
[src]
Shrink the source to discard any unused prefix.
pub fn trim(&mut self)
[src]
Shrink the source to discard any unused prefix or suffix.
pub fn single_span<S>(source: S, attr: T) -> SpannedString<T> where
S: Into<String>,
[src]
S: Into<String>,
Returns a new SpannedString with a single span.
pub fn append<S>(&mut self, other: S) where
S: Into<SpannedString<T>>,
[src]
S: Into<SpannedString<T>>,
Appends the given StyledString
to self
.
pub fn append_raw(&mut self, source: &str, spans: Vec<IndexedSpan<T>, Global>)
[src]
Appends content
and its corresponding spans to the end.
It is not recommended to use this directly;
instead, look at the append
method.
pub fn remove_spans<R>(&mut self, range: R) where
R: RangeBounds<usize>,
[src]
R: RangeBounds<usize>,
Remove the given range of spans from the styled string.
You may want to follow this with either compact()
,
trim_start()
or trim_end()
.
pub fn spans(&self) -> impl DoubleEndedIterator + ExactSizeIterator
[src]
Iterates on the resolved spans.
pub fn spans_attr_mut(&mut self) -> impl Iterator<Item = SpanMut<'_, T>>
[src]
Iterates on the resolved spans, with mutable access to the attributes.
pub fn spans_raw(&self) -> &[IndexedSpan<T>]
[src]
Returns a reference to the indexed spans.
pub fn spans_raw_attr_mut(
&mut self
) -> impl DoubleEndedIterator + ExactSizeIterator
[src]
&mut self
) -> impl DoubleEndedIterator + ExactSizeIterator
Returns a mutable iterator on the spans of this string.
This can be used to modify the style of each span.
pub fn source(&self) -> &str
[src]
Returns a reference to the source string.
This is the non-parsed string.
pub fn is_empty(&self) -> bool
[src]
Returns true
if self is empty.
pub fn width(&self) -> usize
[src]
Returns the width taken by this string.
This is the sum of the width of each span.
Trait Implementations
impl<T> Clone for SpannedString<T> where
T: Clone,
[src]
T: Clone,
pub fn clone(&self) -> SpannedString<T>
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<T> Debug for SpannedString<T> where
T: Debug,
[src]
T: Debug,
impl<T> Default for SpannedString<T>
[src]
pub fn default() -> SpannedString<T>
[src]
impl<T> Eq for SpannedString<T> where
T: Eq,
[src]
T: Eq,
impl<'a, T> From<&'a SpannedString<T>> for SpannedStr<'a, T>
[src]
pub fn from(other: &'a SpannedString<T>) -> SpannedStr<'a, T>
[src]
impl<S, T> From<S> for SpannedString<T> where
S: Into<String>,
T: Default,
[src]
S: Into<String>,
T: Default,
pub fn from(value: S) -> SpannedString<T>
[src]
impl<T> FromIterator<SpannedString<T>> for SpannedString<T>
[src]
pub fn from_iter<I>(iter: I) -> SpannedString<T> where
I: IntoIterator<Item = SpannedString<T>>,
[src]
I: IntoIterator<Item = SpannedString<T>>,
impl<T> Hash for SpannedString<T> where
T: Hash,
[src]
T: Hash,
pub fn hash<__H>(&self, state: &mut __H) where
__H: Hasher,
[src]
__H: Hasher,
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<T> PartialEq<SpannedString<T>> for SpannedString<T> where
T: PartialEq<T>,
[src]
T: PartialEq<T>,
pub fn eq(&self, other: &SpannedString<T>) -> bool
[src]
pub fn ne(&self, other: &SpannedString<T>) -> bool
[src]
impl<'a, T> SpannedText for &'a SpannedString<T>
[src]
type S = IndexedSpan<T>
Type of span returned by SpannedText::spans()
.
pub fn source(&self) -> &str
[src]
pub fn spans(&self) -> &[IndexedSpan<T>]
[src]
pub fn as_ref(&self) -> SpannedTextRef<'_, Self>
[src]
impl<T> StructuralEq for SpannedString<T>
[src]
impl<T> StructuralPartialEq for SpannedString<T>
[src]
Auto Trait Implementations
impl<T> RefUnwindSafe for SpannedString<T> where
T: RefUnwindSafe,
[src]
T: RefUnwindSafe,
impl<T> Send for SpannedString<T> where
T: Send,
[src]
T: Send,
impl<T> Sync for SpannedString<T> where
T: Sync,
[src]
T: Sync,
impl<T> Unpin for SpannedString<T> where
T: Unpin,
[src]
T: Unpin,
impl<T> UnwindSafe for SpannedString<T> where
T: UnwindSafe,
[src]
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> CallHasher for T where
T: Hash + ?Sized,
[src]
T: Hash + ?Sized,
impl<T> Erased for T
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> With for T
[src]
pub fn wrap_with<U, F>(self, f: F) -> U where
F: FnOnce(Self) -> U,
[src]
F: FnOnce(Self) -> U,
pub fn with<F>(self, f: F) -> Self where
F: FnOnce(&mut Self),
[src]
F: FnOnce(&mut Self),
pub fn try_with<E, F>(self, f: F) -> Result<Self, E> where
F: FnOnce(&mut Self) -> Result<(), E>,
[src]
F: FnOnce(&mut Self) -> Result<(), E>,
pub fn with_if<F>(self, condition: bool, f: F) -> Self where
F: FnOnce(&mut Self),
[src]
F: FnOnce(&mut Self),