pub struct AnnotatedString {
pub text: String,
pub span_styles: Vec<RangeStyle<SpanStyle>>,
pub paragraph_styles: Vec<RangeStyle<ParagraphStyle>>,
}Expand description
The basic data structure of text with multiple styles.
To construct an AnnotatedString you can use AnnotatedString::builder().
Fields§
§text: String§span_styles: Vec<RangeStyle<SpanStyle>>§paragraph_styles: Vec<RangeStyle<ParagraphStyle>>Implementations§
Source§impl AnnotatedString
impl AnnotatedString
pub fn new(text: String) -> Self
pub fn builder() -> Builder
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Sourcepub fn span_boundaries(&self) -> Vec<usize>
pub fn span_boundaries(&self) -> Vec<usize>
Returns a sorted list of unique byte indices where styles change.
Sourcepub fn span_styles_hash(&self) -> u64
pub fn span_styles_hash(&self) -> u64
Computes a hash representing the contents of the span styles, suitable for cache invalidation.
Sourcepub fn subsequence(&self, range: Range<usize>) -> Self
pub fn subsequence(&self, range: Range<usize>) -> Self
Returns a new AnnotatedString containing a substring of the original text
and any styles that overlap with the new range, with indices adjusted.
Trait Implementations§
Source§impl Clone for AnnotatedString
impl Clone for AnnotatedString
Source§fn clone(&self) -> AnnotatedString
fn clone(&self) -> AnnotatedString
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for AnnotatedString
impl Debug for AnnotatedString
Source§impl Default for AnnotatedString
impl Default for AnnotatedString
Source§fn default() -> AnnotatedString
fn default() -> AnnotatedString
Returns the “default value” for a type. Read more
Source§impl From<&String> for AnnotatedString
impl From<&String> for AnnotatedString
Source§impl From<&mut String> for AnnotatedString
impl From<&mut String> for AnnotatedString
Source§impl From<&str> for AnnotatedString
impl From<&str> for AnnotatedString
Source§impl From<String> for AnnotatedString
impl From<String> for AnnotatedString
Source§impl PartialEq for AnnotatedString
impl PartialEq for AnnotatedString
impl StructuralPartialEq for AnnotatedString
Auto Trait Implementations§
impl Freeze for AnnotatedString
impl RefUnwindSafe for AnnotatedString
impl Send for AnnotatedString
impl Sync for AnnotatedString
impl Unpin for AnnotatedString
impl UnsafeUnpin for AnnotatedString
impl UnwindSafe for AnnotatedString
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