pub trait EditableText: FormattableText {
    // Required methods
    fn set_string(&mut self, string: String);
    fn insert_char(&mut self, index: usize, c: char);
    fn replace_range(&mut self, range: Range<usize>, replace_with: &str);

    // Provided method
    fn swap_string(&mut self, string: &mut String) { ... }
}
Expand description

Extension of FormattableText allowing editing

Required Methods§

source

fn set_string(&mut self, string: String)

Set unformatted text

Existing contents and formatting are replaced entirely.

source

fn insert_char(&mut self, index: usize, c: char)

Insert a char at the given position

Formatting is adjusted such that it still affects the same chars (i.e. all formatting after index is postponed by the length of the char).

source

fn replace_range(&mut self, range: Range<usize>, replace_with: &str)

Replace text at range with replace_with

Formatting is adjusted such that it still affects the same chars.

Provided Methods§

source

fn swap_string(&mut self, string: &mut String)

Swap the contiguous unformatted text with another string

Any formatting present is removed.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl EditableText for String

source§

fn set_string(&mut self, string: String)

source§

fn swap_string(&mut self, string: &mut String)

source§

fn insert_char(&mut self, index: usize, c: char)

source§

fn replace_range(&mut self, range: Range<usize>, replace_with: &str)

Implementors§