pub struct Once<T>(_, _);
A type whose inner value can be written once and then will stay read-only
Creates an Once value which is uninitialized
Consumes the value and returns Some(T) if it was initialized
Tries to initialize the inner value to value
.
Returns None
if the inner value was uninitialized and value
was
consumed setting it otherwise if the inner value was already set it
returns value
back to the caller
Tries to initialize the inner value to value
.
Returns None
if the inner value was uninitialized and value
was
consumed setting it otherwise if the inner value was already set it
asserts that value
is equal to the inner value and then returns
value
back to the caller
Tries to initialize the inner value to value
and panics if it was
already initialized
Tries to initialize the inner value by calling the closure while
ensuring that no-one else can access the value in the mean time by
holding a lock for the duration of the closure. If the value was
already initialized the closure is not called and false
is returned,
otherwise if the value from the closure initializes the inner value,
true
is returned
Tries to initialize the inner value by calling the closure without
ensuring that no-one else can access it. This mean when this is
called from multiple threads, multiple closures may concurrently be
computing a value which the inner value should take. Only one of
these closures are used to actually initialize the value.
If some other closure already set the value,
we return the value our closure computed wrapped in a Option
.
If our closure set the value, None
is returned.
If the value is already initialized, the closure is not called and
None
is returned.
Tries to initialize the inner value by calling the closure without
ensuring that no-one else can access it. This mean when this is
called from multiple threads, multiple closures may concurrently be
computing a value which the inner value should take. Only one of
these closures are used to actually initialize the value.
If some other closure already set the value, we assert that it our
closure computed a value equal to the value already set and then
we return the value our closure computed wrapped in a Option
.
If our closure set the value, None
is returned.
If the value is already initialized, the closure is not called and
None
is returned.
Tries to get a reference to the inner value, returns None
if it is not
yet initialized
Gets reference to the inner value, panics if it is not yet initialized
Gets reference to the inner value, panics if it is not yet initialized
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
Immutably borrows from an owned value. Read more
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static
Mutably borrows from an owned value. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)