ValueOr
Consumes the selected value or an eagerly supplied fallback.
Module std.prelude
import std.prelude;Public declaration contracts and authored examples. A page can document several related symbols. Implementation bodies are excluded.
ValueOr
pub fn ValueOr<T, E>(mut Value: Result<T, E>, mut Fallback: T) -> T
where T: Movable where E: MovableConsumes the selected value or an eagerly supplied fallback.
The unreturned fallback/payload is destroyed normally. No default evaluation is delayed and no allocation, copying or implicit error logging is introduced. T: Movable success/optional payload, including exact reference payloads. E: Movable error discarded on fallback selection. Value: Owned wrapper consumed by this call. Fallback: Owned eager fallback, consumed on absence/error and otherwise destroyed. Return: Owned selected value or Fallback; reference payloads remain aliases.
ValueOr
pub fn ValueOr<T>(mut Value: T?, mut Fallback: T) -> T
where T: MovableConsumes the selected value or an eagerly supplied fallback.
The unreturned fallback/payload is destroyed normally. No default evaluation is delayed and no allocation, copying or implicit error logging is introduced. T: Movable success/optional payload, including exact reference payloads. Value: Owned wrapper consumed by this call. Fallback: Owned eager fallback, consumed on absence/error and otherwise destroyed. Return: Owned selected value or Fallback; reference payloads remain aliases.