Skip to main content

Span

Struct Span 

Source
pub struct Span { /* private fields */ }
Expand description

A span consists of a list of styles to apply to an inner list of inline content.

Implementations§

Source§

impl Span

Source

pub fn with_style(inner: &str, style: SpanStyle) -> Self

Create a new span, with the provided style, that includes a Text instance.

Source

pub fn with_styles(inner: &str, styles: Vec<SpanStyle>) -> Self

Create a new span, with the provided styles, that includes a Text instance.

Source

pub fn inner_with_style(inner: InlineContent, style: SpanStyle) -> Self

Create a new span, with the provided style, that includes a InlineContent instance.

Source

pub fn inner_with_styles(inner: InlineContent, styles: Vec<SpanStyle>) -> Self

Create a new span, with the provided style, that includes a InlineContent instance.

Source

pub fn space() -> Self

Create a new span containing simply a space character.

Trait Implementations§

Source§

impl Clone for Span

Source§

fn clone(&self) -> Span

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Span

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Span

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Span

Source§

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 From<&str> for Span

Source§

fn from(s: &str) -> Self

Converts to this type from the input type.
Source§

impl From<InlineContent> for Span

Source§

fn from(value: InlineContent) -> Self

Converts to this type from the input type.
Source§

impl From<String> for Span

Source§

fn from(s: String) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<InlineContent>> for Span

Source§

fn from(value: Vec<InlineContent>) -> Self

Converts to this type from the input type.
Source§

impl HasInlineContent for Span

Create a new inline content container from the provided HyperLink content item.
Source§

fn image(inner: Image) -> Self

Create a new inline content container from the provided Image content item.
Source§

fn text(inner: Text) -> Self

Create a new inline content container from the provided Text content item.
Source§

fn math(inner: Math) -> Self

Create a new inline content container from the provided Math content item.
Source§

fn text_str(inner: &str) -> Self

Create a new inline content container from the provided string (into Text) content item.
Source§

fn character(inner: Character) -> Self

Create a new inline content container from the provided Character content item.
Source§

fn line_break() -> Self

Create a new inline content container with a line break.
Source§

fn span(span: Span) -> Self

Create a new inline content container from the provided Span content item.
Add the provided HyperLink to this container’s inner content.
Source§

fn add_image(&mut self, inner: Image) -> &mut Self

Add the provided Image to this container’s inner content.
Source§

fn add_text(&mut self, inner: Text) -> &mut Self

Add the provided Text to this container’s inner content.
Source§

fn add_text_str(&mut self, inner: &str) -> &mut Self

Add the provided string (as Text) to this container’s inner content.
Source§

fn add_math(&mut self, inner: Math) -> &mut Self

Add the provided Math to this container’s inner content.
Source§

fn add_character(&mut self, inner: Character) -> &mut Self

Add the provided Character to this container’s inner content.
Source§

fn add_space(&mut self) -> &mut Self

Add a single space to this container’s inner content.
Source§

fn add_non_breaking_space(&mut self) -> &mut Self

Add a single non-breaking space to this container’s inner content.
Source§

fn add_line_break(&mut self) -> &mut Self

Add a LineBreak to this container’s inner content.
Source§

fn add_span(&mut self, inner: Span) -> &mut Self

Add the provided Span to this container’s inner content.
Source§

fn plain(inner: InlineContent) -> Self

Create a new inline content container as a Span, with TextStyle::Plain applied to the provided content.
Source§

fn plain_str(inner: &str) -> Self

Create a new inline content container as a Span, with TextStyle::Plain applied to the provided string as a Text instance.
Source§

fn italic(inner: InlineContent) -> Self

Create a new inline content container as a Span, with TextStyle::Italic applied to the provided content.
Source§

fn italic_str(inner: &str) -> Self

Create a new inline content container as a Span, with TextStyle::Italic applied to the provided string as a Text instance.
Source§

fn bold(inner: InlineContent) -> Self

Create a new inline content container as a Span, with TextStyle::Bold applied to the provided content.
Source§

fn bold_str(inner: &str) -> Self

Create a new inline content container as a Span, with TextStyle::Bold applied to the provided string as a Text instance.
Source§

fn mono(inner: InlineContent) -> Self

Create a new inline content container as a Span, with TextStyle::Mono applied to the provided content.
Source§

fn mono_str(inner: &str) -> Self

Create a new inline content container as a Span, with TextStyle::Mono applied to the provided string as a Text instance.
Source§

fn code(inner: InlineContent) -> Self

Create a new inline content container as a Span, with TextStyle::Code applied to the provided content.
Source§

fn code_str(inner: &str) -> Self

Create a new inline content container as a Span, with TextStyle::Code applied to the provided string as a Text instance.
Source§

fn strikethrough(inner: InlineContent) -> Self

Create a new inline content container as a Span, with TextStyle::Strikethrough applied to the provided content.
Source§

fn strikethrough_str(inner: &str) -> Self

Create a new inline content container as a Span, with TextStyle::Strikethrough applied to the provided string as a Text instance.
Source§

fn underline(inner: InlineContent) -> Self

Create a new inline content container as a Span, with TextStyle::Underline applied to the provided content.
Source§

fn underline_str(inner: &str) -> Self

Create a new inline content container as a Span, with TextStyle::Underline applied to the provided string as a Text instance.
Source§

fn small_caps(inner: InlineContent) -> Self

Create a new inline content container as a Span, with TextStyle::SmallCaps applied to the provided content.
Source§

fn small_caps_str(inner: &str) -> Self

Create a new inline content container as a Span, with TextStyle::SmallCaps applied to the provided string as a Text instance.
Source§

fn superscript(inner: InlineContent) -> Self

Create a new inline content container as a Span, with TextStyle::Superscript applied to the provided content.
Source§

fn superscript_str(inner: &str) -> Self

Create a new inline content container as a Span, with TextStyle::Superscript applied to the provided string as a Text instance.
Source§

fn subscript(inner: InlineContent) -> Self

Create a new inline content container as a Span, with TextStyle::Subscript applied to the provided content.
Source§

fn subscript_str(inner: &str) -> Self

Create a new inline content container as a Span, with TextStyle::Subscript applied to the provided string as a Text instance.
Source§

fn unformatted_string(&self) -> String

Return a string that is simply the Text instances (recursively) concatenated. This removes any style information and non-text instances such as images or links.
Source§

impl HasInnerContent<InlineContent> for Span

Source§

fn inner(&self) -> &Vec<InlineContent>

Return a reference to the inner value.
Source§

fn into_inner(self) -> Vec<InlineContent>

Return the inner value, consuming self.
Source§

fn inner_mut(&mut self) -> &mut Vec<InlineContent>

Return a mutable reference to the inner list of content.
Source§

fn add_content(&mut self, content: InlineContent) -> Result<()>

Add content to the inner list of content. If there is some consistency condition that would be broken by this addition an error will be returned.
Source§

fn has_inner(&self) -> bool

Returns true if the inner list of content is not empty, else false.
Source§

impl HasStyles<SpanStyle> for Span

Source§

fn styles(&self) -> &Vec<SpanStyle>

Return a reference to the list of applied styles.
Source§

fn styles_mut(&mut self) -> &mut Vec<SpanStyle>

Return a mutable reference to the list of applied styles.
Source§

fn add_style(&mut self, style: SpanStyle) -> Result<()>

Add content to the list of applied styles. If there is some consistency condition that would be broken by this addition an error will be returned.
Source§

fn has_styles(&self) -> bool

Returns true if the list of applied styles is not empty, else false.
Source§

impl Into<InlineContent> for Span

Source§

fn into(self) -> InlineContent

Converts this type into the (usually inferred) input type.
Source§

impl Serialize for Span

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl Freeze for Span

§

impl RefUnwindSafe for Span

§

impl Send for Span

§

impl Sync for Span

§

impl Unpin for Span

§

impl UnsafeUnpin for Span

§

impl UnwindSafe for Span

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.