Struct takeable::Takeable [] [src]

pub struct Takeable<T> { /* fields omitted */ }

A wrapper-type that always holds a single T value.

This type is implemented using an Option<T>, however outside of the borrow_result function, this Option will always contain a value.

Panics

If the closure given to borrow or borrow_result panics, then the Takeable is left in an unusable state without holding a T. Calling any method on the object besides is_usable when in this state will result in a panic. This includes trying to dereference the object.

It is still safe to drop the value.

Methods

impl<T> Takeable<T>
[src]

Constructs a new Takeable<T> value.

Gets a reference to the inner value.

Gets a mutable reference to the inner value.

Takes ownership of the inner value.

Updates the inner value using the provided closure.

Updates the inner value using the provided closure while also returns a result.

Check if the object is still usable.

The object will always start out as usable, and can only enter an unusable state if the methods borrow or borrow_result are called with closures that panic.

Trait Implementations

impl<T: Clone> Clone for Takeable<T>
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl<T: Copy> Copy for Takeable<T>
[src]

impl<T: Debug> Debug for Takeable<T>
[src]

Formats the value using the given formatter.

impl<T: Eq> Eq for Takeable<T>
[src]

impl<T: PartialEq> PartialEq for Takeable<T>
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl<T: Ord> Ord for Takeable<T>
[src]

This method returns an Ordering between self and other. Read more

🔬 This is a nightly-only experimental API. (ord_max_min)

Compares and returns the maximum of two values. Read more

🔬 This is a nightly-only experimental API. (ord_max_min)

Compares and returns the minimum of two values. Read more

impl<T: PartialOrd> PartialOrd for Takeable<T>
[src]

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl<T: Hash> Hash for Takeable<T>
[src]

Feeds this value into the given [Hasher]. Read more

Feeds a slice of this type into the given [Hasher]. Read more

impl<T: Default> Default for Takeable<T>
[src]

Returns the "default value" for a type. Read more

impl<T> Deref for Takeable<T>
[src]

The resulting type after dereferencing

The method called to dereference a value

impl<T> DerefMut for Takeable<T>
[src]

The method called to mutably dereference a value