[][src]Struct cursive::utils::span::SpannedString

pub struct SpannedString<T> { /* fields omitted */ }

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]

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]

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]

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]

Appends text to self, using style.

impl SpannedString<()>[src]

pub fn plain<S>(content: S) -> SpannedString<()> where
    S: Into<String>, 
[src]

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]

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]

Returns a new SpannedString with a single span.

pub fn append<S>(&mut self, other: S) where
    S: Into<SpannedString<T>>, 
[src]

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]

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]

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]

impl<T> Debug for SpannedString<T> where
    T: Debug
[src]

impl<T> Default for SpannedString<T>[src]

impl<T> Eq for SpannedString<T> where
    T: Eq
[src]

impl<'a, T> From<&'a SpannedString<T>> for SpannedStr<'a, T>[src]

impl<S, T> From<S> for SpannedString<T> where
    S: Into<String>,
    T: Default
[src]

impl<T> FromIterator<SpannedString<T>> for SpannedString<T>[src]

impl<T> Hash for SpannedString<T> where
    T: Hash
[src]

impl<T> PartialEq<SpannedString<T>> for SpannedString<T> where
    T: PartialEq<T>, 
[src]

impl<'a, T> SpannedText for &'a SpannedString<T>[src]

type S = IndexedSpan<T>

Type of span returned by SpannedText::spans().

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]

impl<T> Send for SpannedString<T> where
    T: Send
[src]

impl<T> Sync for SpannedString<T> where
    T: Sync
[src]

impl<T> Unpin for SpannedString<T> where
    T: Unpin
[src]

impl<T> UnwindSafe for SpannedString<T> where
    T: UnwindSafe
[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> CallHasher for T where
    T: Hash + ?Sized
[src]

impl<T> Erased for T

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> With for T[src]