Skip to content

v0.8.0

Compare
Choose a tag to compare
@mcmah309 mcmah309 released this 05 Dec 16:56
· 12 commits to master since this release

Generics

error_set now supports generics. e.g.

error_set! {
    X<G: Debug> = {
        A {
            a: G
        }
    };
    Y<H: Debug> = {
        B {
            b: H
        }
    };
    Z<T: Debug> = X<T> || Y<T>;
}

In Z<T: Debug> = X<T> || Y<T>; T will replace G in X - X<T: Debug>. Thus this statement is the
same as writing

error_set! {
    ...

    Z<T: Debug> = {
        A {
            a: T
        },
        B {
            b: T
        }
    };
}

Disable

error_set auto-implements From, Display, Debug, and Error for the set. If it is ever desired to disable
this. Add #[disable(..)] to the set. e.g.

error_set! {
    #[disable(Display,Debug)]
    X = {
        A,
    };
}

impl Display for X {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        write!(f, "X")
    }
}

impl Debug for X {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        write!(f, "X")
    }
}

Breaking

If two variants share the same source, the From implementation will not automatically be generated.

Full Changelog: v0.7.0...v0.8.0