[−][src]Struct cursive::utils::span::SpannedString
A string with associated spans.
Each span has an associated attribute T
.
Methods
impl SpannedString<Style>
[src]
pub fn plain<S>(content: S) -> Self 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) -> Self 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) -> Self where
S: Into<String>,
[src]
S: Into<String>,
Returns a simple spanned string without any attribute.
impl<T> SpannedString<T>
[src]
pub fn new() -> Self
[src]
Returns an empty SpannedString
.
pub fn with_spans<S>(source: S, spans: Vec<IndexedSpan<T>>) -> Self where
S: Into<String>,
[src]
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 single_span<S>(source: S, attr: T) -> Self 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<Self>,
[src]
S: Into<Self>,
Appends the given StyledString
to self
.
pub fn append_raw(&mut self, source: &str, spans: Vec<IndexedSpan<T>>)
[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 spans(&self) -> impl Iterator<Item = Span<T>>
[src]
Gives access to the parsed styled spans.
pub fn spans_raw(&self) -> &[IndexedSpan<T>]
[src]
Returns a reference to the indexed spans.
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<'a, T> SpannedText for &'a SpannedString<T>
[src]
type S = IndexedSpan<T>
Type of span returned by SpannedText::spans()
.
fn source(&self) -> &str
[src]
fn spans(&self) -> &[IndexedSpan<T>]
[src]
fn as_ref(&self) -> SpannedTextRef<Self>
[src]
Returns a SpannedText
by reference.
impl<T: Clone> Clone for SpannedString<T>
[src]
fn clone(&self) -> SpannedString<T>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<T> Default for SpannedString<T>
[src]
impl<S, T> From<S> for SpannedString<T> where
S: Into<String>,
T: Default,
[src]
S: Into<String>,
T: Default,
impl<'a, T> From<&'a SpannedString<T>> for SpannedStr<'a, T>
[src]
fn from(other: &'a SpannedString<T>) -> Self
[src]
impl<T: PartialEq> PartialEq<SpannedString<T>> for SpannedString<T>
[src]
fn eq(&self, other: &SpannedString<T>) -> bool
[src]
fn ne(&self, other: &SpannedString<T>) -> bool
[src]
impl<T: Eq> Eq for SpannedString<T>
[src]
impl<T: Debug> Debug for SpannedString<T>
[src]
Auto Trait Implementations
impl<T> Sync for SpannedString<T> where
T: Sync,
T: Sync,
impl<T> Send for SpannedString<T> where
T: Send,
T: Send,
impl<T> Unpin for SpannedString<T> where
T: Unpin,
T: Unpin,
impl<T> RefUnwindSafe for SpannedString<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> UnwindSafe for SpannedString<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
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.
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.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,