#bounds #equality #type #coercing

eq-type

Allows declaring an equality bound on two types and coercing between them

1 unstable release

0.1.0 Jun 7, 2022

#35 in #equality

MIT/Apache

3KB
55 lines

eq-type

See the docs.


lib.rs:

A crate that allows declaring an equality bound on two types and coercing between them.

Examples

#
pub trait ResultExt<T, E>: Sized + Is<Result<T, E>> {
    /// Given any `E` and `EI` that implement `Into<ER>`, converts from Result<Result<T, EI>, E> to Result<T, ER>.
    fn flatten_into<TI, EI, ER>(self) -> Result<TI, ER>
    where
        T: Is<Result<TI, EI>>,
        E: Into<ER>,
        EI: Into<ER>,
    {
        self.coerce().map_err(|e| e.into()).and_then(|x| x.coerce().map_err(|e| e.into()))
    }
}
#

No runtime deps