Skip to main content

History

Struct History 

Source
pub struct History<T, L = String> { /* private fields */ }
Expand description

元に戻す段(前の状態と、その状態から次への変更の名前 L)と、やり直す段

Implementations§

Source§

impl<T, L> History<T, L>

Source

pub fn new(depth: usize) -> Self

深さ depth(1 以上)の空の履歴

Source

pub fn record(&mut self, prev: T, label: L)

変更の前の状態 prev を積む(やり直す段は捨てる)

Source

pub fn record_or_merge(&mut self, prev: T, label: L, merge: bool)

merge なら前の段にまとめて積まない(元に戻す段が無ければ積む)。どちらでもやり直す段は捨てる

Source

pub fn step(&mut self, cur: T, back: bool) -> Option<T>

1 段戻す(back)・やり直す: 今の状態 cur を反対の段に積み、戻した先の状態を返す。段が無ければ None

Source

pub fn pop(&mut self, back: bool) -> Option<(T, L)>

戻す(back)・やり直す段の一番上を取り出す(反対の段には積まない。Self::pass と組で使う)

Source

pub fn pass(&mut self, back: bool, item: (T, L))

Self::pop で戻した(back)・やり直した段の代わりに、反対の段へ積む(やり直す段は捨てない)

Source

pub fn clear_redo(&mut self)

やり直す段を捨てる

Source

pub fn len(&self, back: bool) -> usize

元に戻せる(back)・やり直せる段の数

Source

pub fn is_empty(&self, back: bool) -> bool

元に戻せる(back)・やり直せる段が無い

Source

pub fn top(&self, back: bool) -> Option<&(T, L)>

次に戻す(back)・やり直す段

Source

pub fn labels(&self, back: bool) -> impl Iterator<Item = &L>

段の名前(元に戻す段は新しい順、やり直す段は次にやり直す順)

Trait Implementations§

Source§

impl<T: Clone, L: Clone> Clone for History<T, L>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug, L: Debug> Debug for History<T, L>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T, L> Default for History<T, L>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<T, L> Freeze for History<T, L>

§

impl<T, L> RefUnwindSafe for History<T, L>

§

impl<T, L> Send for History<T, L>
where T: Send, L: Send,

§

impl<T, L> Sync for History<T, L>
where T: Sync, L: Sync,

§

impl<T, L> Unpin for History<T, L>
where T: Unpin, L: Unpin,

§

impl<T, L> UnsafeUnpin for History<T, L>

§

impl<T, L> UnwindSafe for History<T, L>
where T: UnwindSafe, L: UnwindSafe,

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.