Struct simple_text_editor::text::Text [−][src]
Represents the buffer of characters which are operated on by the commands, and the stack of operations that are eligible for undo commands.
Implementations
impl Text
[src]
use simple_text_editor::ops; use simple_text_editor::text::Text; let (num_ops, ops) = ops::parse(r#"4 1 hello 2 1 2 1 1 p me! "#).unwrap(); let mut text = Text::new("", num_ops); text.apply(ops); assert_eq!(text.output(), "help me!".to_string());
pub fn new(init: impl AsRef<str>, num_ops: usize) -> Self
[src]
Creates a new Text
instance, which can start from an initial state instead of an empty buffer.
pub fn apply(&mut self, ops: Vec<Operation<'_>>)
[src]
Mutates the Text
instance by executing each operation in ops
serially.
pub fn output(self) -> String
[src]
Returns the current state of the Text
instance's internal buffer.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Text
[src]
impl Send for Text
[src]
impl Sync for Text
[src]
impl Unpin for Text
[src]
impl UnwindSafe for Text
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,