pub struct SpannedString<T> { /* private fields */ }
Expand description

A string with associated spans.

Each span has an associated attribute T.

Implementations§

Returns a plain StyledString without any style.

You got no style, Dutch. You know that.

Creates a new StyledString using a single style for the entire text.

Appends the given plain text to self.

Appends text to self, using style.

Returns a simple spanned string without any attribute.

Returns an empty SpannedString.

Creates a new SpannedString manually.

It is not recommended to use this directly. Instead, look for methods like Markdown::parse.

Compacts the source to only include the spans content.

Shrink the source to discard any unused suffix.

Shrink the source to discard any unused prefix.

Shrink the source to discard any unused prefix or suffix.

Returns a new SpannedString with a single span.

Appends the given StyledString to self.

Appends content and its corresponding spans to the end.

It is not recommended to use this directly; instead, look at the append method.

Remove the given range of spans from the styled string.

You may want to follow this with either compact(), trim_start() or trim_end().

Iterates on the resolved spans.

Iterates on the resolved spans, with mutable access to the attributes.

Returns a reference to the indexed spans.

Returns a mutable iterator on the spans of this string.

This can be used to modify the style of each span.

Returns a reference to the source string.

This is the non-parsed string.

Returns true if self is empty.

Returns the width taken by this string.

This is the sum of the width of each span.

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more
Converts to this type from the input type.
Converts to this type from the input type.
Creates a value from an iterator. Read more
Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
Type of span returned by SpannedText::spans().
Returns the source text.
Returns the spans for this text.
Returns a SpannedText by reference.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

Should always be Self
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.