Struct simple_text_editor::text::Text[][src]

pub struct Text { /* fields omitted */ }

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

impl Debug for Text[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.