Skip to content

Instantly share code, notes, and snippets.

@skade
Last active December 12, 2017 19:57
Show Gist options
  • Save skade/53e4afb98786739ef2cdba3195e62e18 to your computer and use it in GitHub Desktop.
Save skade/53e4afb98786739ef2cdba3195e62e18 to your computer and use it in GitHub Desktop.
use std::fmt::Debug;
fn wrap<A, B>(item: A, f: fn(A) -> B) -> B {
f(item)
}
fn main() {
println!("{:?}", wrap(1, Hoge::Fuga));
println!("{:?}", wrap(1, Foo::Bar));
}
#[derive(Debug)]
enum Hoge<T>
where
T: Debug,
{
Fuga(T),
Piyo(T),
}
#[derive(Debug)]
enum Foo<T>
where
T: Debug,
{
Bar(T),
Batz(T),
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment