MapResult
Consumes one wrapper and invokes its safe callback only for the selected case.
Module std.prelude
import std.prelude;Public declaration contracts and authored examples. A page can document several related symbols. Implementation bodies are excluded.
MapResult
pub fn MapResult<T, U, E>(mut Value: Result<T, E>, Mapper: fn(T) -> U) -> Result<U, E>
where T: Movable where U: Movable where E: MovableConsumes one wrapper and invokes its safe callback only for the selected case.
Unselected owned payloads transfer without copying. The callback is invoked exactly once for the selected case and never for the other case; callback captures/costs keep their own contract. This helper adds no allocation, synchronization or implicit error propagation. Reference payloads remain aliases. T: Exact movable payload representation. U: Exact movable payload representation. E: Exact movable payload representation. Value: Owned wrapper consumed by this call; explicitly move noncopy named inputs. Mapper: Nonnullable safe callback with exact input/output types. Return: Transformed selected payload or preserved opposite case.
MapResult
pub fn MapResult<T, U, E, C>(mut Value: Result<T, E>, mut Mapper: C) -> Result<U, E>
where T: Movable where U: Movable where E: Movable where C: UnaryCallable<T, U>, MovableConsumes one wrapper and invokes its safe callback only for the selected case.
Unselected owned payloads transfer without copying. The callback is invoked exactly once for the selected case and never for the other case; callback captures/costs keep their own contract. This helper adds no allocation, synchronization or implicit error propagation. Reference payloads remain aliases. T: Exact movable payload representation. U: Exact movable payload representation. E: Exact movable payload representation. C: Concrete movable exact safe readonly callback environment. Value: Owned wrapper consumed by this call; explicitly move noncopy named inputs. Mapper: Owned concrete safe callback with exact input/output types. Return: Transformed selected payload or preserved opposite case.
MapResult
pub fn MapResult<U, E>(mut Value: Result<void, E>, Mapper: fn() -> U) -> Result<U, E>
where U: Movable where E: MovableConsumes payloadless success and invokes a safe zero-argument callback. U: Movable resulting success representation. E: Movable error representation, transferred without copying. Value: Owned void-success wrapper. Mapper: Nonnullable safe callback invoked only on Ok. Return: Selected mapped result or preserved Err.
MapResult
pub fn MapResult<U, E, C>(mut Value: Result<void, E>, mut Mapper: C) -> Result<U, E>
where U: Movable where E: Movable where C: NullaryCallable<U>, MovableConsumes void success and invokes an owned safe zero-argument environment. U: Movable resulting success representation. E: Movable preserved error representation. C: Exact movable safe readonly NullaryCallable environment. Value: Owned void-success wrapper consumed by the call. Mapper: Owned environment; invoked only once on success, never on error. Return: Mapped callback result or transferred original error; no helper allocation.