pub struct Span<'a> {
pub content: Cow<'a, str>,
pub style: Style,
}Expand description
A styled span of text.
The most basic text primitive representing a single string with a style.
§Example
use tuxtui_core::text::Span;
use tuxtui_core::style::{Color, Style};
let span = Span::styled("Hello", Style::default().fg(Color::Blue));Fields§
§content: Cow<'a, str>The text content
style: StyleThe style for this span
Implementations§
Source§impl<'a> Span<'a>
impl<'a> Span<'a>
Sourcepub fn raw<T: Into<Cow<'a, str>>>(content: T) -> Self
pub fn raw<T: Into<Cow<'a, str>>>(content: T) -> Self
Create a new span with the given content and default style.
Sourcepub fn styled<T: Into<Cow<'a, str>>>(content: T, style: Style) -> Self
pub fn styled<T: Into<Cow<'a, str>>>(content: T, style: Style) -> Self
Create a new span with the given content and style.
Sourcepub fn into_owned(self) -> Span<'static>
pub fn into_owned(self) -> Span<'static>
Convert this span to an owned version.
Sourcepub fn patch_style(self, style: Style) -> Self
pub fn patch_style(self, style: Style) -> Self
Patch the style of this span.
Trait Implementations§
Source§impl<'de, 'a> Deserialize<'de> for Span<'a>
impl<'de, 'a> Deserialize<'de> for Span<'a>
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<'a> Stylize for Span<'a>
impl<'a> Stylize for Span<'a>
Source§fn underlined(self) -> Self
fn underlined(self) -> Self
Make the text underlined.
Source§fn slow_blink(self) -> Self
fn slow_blink(self) -> Self
Make the text blink slowly.
Source§fn rapid_blink(self) -> Self
fn rapid_blink(self) -> Self
Make the text blink rapidly.
Make the text hidden.
Source§fn crossed_out(self) -> Self
fn crossed_out(self) -> Self
Make the text crossed out.
impl<'a> Eq for Span<'a>
impl<'a> StructuralPartialEq for Span<'a>
Auto Trait Implementations§
impl<'a> Freeze for Span<'a>
impl<'a> RefUnwindSafe for Span<'a>
impl<'a> Send for Span<'a>
impl<'a> Sync for Span<'a>
impl<'a> Unpin for Span<'a>
impl<'a> UnwindSafe for Span<'a>
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.