Owning

Struct Owning 

Source
pub struct Owning<T, Undo: FnOnce(T) -> T> { /* private fields */ }
Expand description

Caries an undo operation + an owned mutable value

See own for examples

Implementations§

Source§

impl<T, Undo: FnOnce(T) -> T> Owning<T, Undo>

Source

pub fn get(&self) -> &T

Source

pub fn get_mut(&mut self) -> &mut T

Trait Implementations§

Source§

impl<T, Undo: FnOnce(T) -> T> Atom for Owning<T, Undo>

Source§

fn decay(self) -> Self::Decay

Returns the modified part

let mut items = rewind::own_id(vec!["hello", "world"]);
items.push("wow");
let items = items.decay();
assert_eq!(items.get(2), Some(&"wow"));
Source§

type Undo = T

Source§

type Decay = T

Source§

fn undo(self) -> Self::Undo

Undo the operation Read more
Source§

impl<T: Debug, Undo: FnOnce(T) -> T> Debug for Owning<T, Undo>

Source§

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

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

impl<T, Undo: FnOnce(T) -> T> Deref for Owning<T, Undo>

Source§

type Target = T

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<T, Undo: FnOnce(T) -> T> DerefMut for Owning<T, Undo>

Source§

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

Mutably dereferences the value.
Source§

impl<T, Undo: FnOnce(T) -> T> Drop for Owning<T, Undo>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<T, Undo> Freeze for Owning<T, Undo>
where T: Freeze, Undo: Freeze,

§

impl<T, Undo> RefUnwindSafe for Owning<T, Undo>
where T: RefUnwindSafe, Undo: RefUnwindSafe,

§

impl<T, Undo> Send for Owning<T, Undo>
where T: Send, Undo: Send,

§

impl<T, Undo> Sync for Owning<T, Undo>
where T: Sync, Undo: Sync,

§

impl<T, Undo> Unpin for Owning<T, Undo>
where T: Unpin, Undo: Unpin,

§

impl<T, Undo> UnwindSafe for Owning<T, Undo>
where T: UnwindSafe, Undo: 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> 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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

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

Source§

type Error = Infallible

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

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

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.