pub struct Constructible<T> { /* private fields */ }
👎 Deprecated since 0.7.13:

use once_cell

Expand description

A cell that can be initialized, but only once.
Once initialized the cell remains immutable, allowing us to alias the value.

NB: There is a similar abstraction at https://github.com/matklad/once_cell. (I’ve only just discovered it, some months after implementing the Constructible myself).

Implementations

Provides the cell with the value.
The value is effectively pinned in the cell, it won’t be moved.
Returns an error if the cell is already initialized.

Provides the cell with the value.
The value is moved into a Box and pinned there.
Returns an error if the cell is already initialized.

Get a reference to the value.
If the value is not (yet) available then returns the reference provided by default.

Returns a copy of the value or the default if the value is not yet available.

Returns a clone of the value or the default if the value is not yet available.

Returns a reference to the value or the given error if the value is not yet available.

Returns a reference to the value or None if the value is not yet available.

True if the value is not yet available.

True if the cell is now initialized with a value.

Returns a reference to the value unless it was not yet initialized.

Trait Implementations

Debug formatting similar to Option<&T>.

Formats the value using the given formatter. Read more

Creates a cell without a value.
Use pin or initialize to provide the value later.

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

Prints the value or “-” if it is not yet available.

Formats the value using the given formatter. Read more

Executes the destructor for this type. Read more

Translate an Option into a Constructible cell.
If the Option has a value then the cell with be initialized with it.
If the Option is empty then the cell will be empty as well, and waiting for delayed initialization.

Performs the conversion.

Pre-initialize the cell with the given value.

Performs the conversion.

Allows to parse directly into the cell.

The associated error which can be returned from parsing.

Parses a string s to return a value of this type. Read more

Makes it possible to access the value with a for loop.

for value in &constructible {println! ("{}", value)}

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Creates an iterator from a value. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Returns the argument unchanged.

Calls U::from(self).

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

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.