pub struct Memento {
    name: String,
    text: String,
}
Expand description

Represents a single memento (snapshot) of the text state before an operation is applied. The operation becomes the name of the memento for display purposes.

Fields§

§name: String

The name of this memento (really just the name of the operation that triggered the need for this memento).

§text: String

The snapshot of the text data as stored in the MementoTextObject struct instance.

Implementations§

source§

impl Memento

source

fn new(name: &str, text: &str) -> Memento

Constructor.

Parameters
  • name

    The name of the memento to create

  • text

    The data to be saved in the memento

Returns

Returns a new instance of the Memento struct.

source

fn text(&self) -> &str

The saved text in this memento. This is accessible only by the MementoTextObject struct since it is the only entity that knows what to do with the text during an undo.

source

pub fn name(&self) -> &str

The name of the memento (snapshot). Useful for displaying a list of mementos in an undo list. In this case, the name of each memento is the operation that triggered the creation of the memento.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

source§

fn vzip(self) -> V