sumtype 0.4.0

Generate zerocost anonymous sum types that implement common traits
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
use std::io::Read;
use sumtype::sumtype;

#[allow(unused)]
#[sumtype(sumtype::traits::Read)]
fn f1(a: bool) -> impl Read {
    if a {
        sumtype!(std::io::empty())
    } else {
        sumtype!(std::io::Cursor::new([1, 2, 3]))
    }
}