This post is auto-generated from RSS feed
The Rust Programming Language Forum - Latest topics . Source:
Please - give me cases that break this generic implementation of map() etc
Hey folks,
Just crawling out of a rabbit-hole after spending a few hours crafting Try-related trait bounds and generic implementations of map, zip, transpose etc for any TryType
use std::ops::{ControlFlow, FromResidual, Residual, Try};
/// Methods for transforming TryTypes. Inspired by the methods provided on `Option` & `Result`
///
/// ## Note
///
/// - Methods which act on the contained value are only available for the *Output* case. TryTypes
/// are recommended to directly implement equivalent methods for *Residual* cases with suitable
/// naming. E.g. we provide a `.map()` but not a `.map_err()` equivalent as multiple such
/// methods may be needed and no standardised naming makes sense.
/// - Methods which act on the contained value will extract a value of type `Output` and return the
/// *canonical TryType* for the new Output. This is identifiable by the generic type `X` in the
/// method signature. This is usually the expected behaviour but can lead to a different value
/// type or resulting TryType where `Try` is not implemented symmetrically.
/// - Generic type conventions used in signatures (in standard order):
/// - `X` the *canonical TryType* returned
/// - `Y` the other TryType
/// - `T` the `Output` type for `Self`
/// - `U` the other `Output` type
/// - `F` a function/closure passed as a parameter
This file has been truncated. show original
I'd be really grateful for ideas of cases where this is broken.
Thanks!
1 post - 1 participant
Read full topic
🏷️ Rust_feed