Skip to content

Instantly share code, notes, and snippets.

@JoeyEremondi
Last active October 19, 2016 20:21
Show Gist options
  • Save JoeyEremondi/63ebd1b19a3c73d8c01c6393ecf5344b to your computer and use it in GitHub Desktop.
Save JoeyEremondi/63ebd1b19a3c73d8c01c6393ecf5344b to your computer and use it in GitHub Desktop.
use std::borrow::Borrow;
use std::boxed::Box;
enum Foo {
Bar,
Baz,
}
fn compare<T1 : Borrow<Foo>, T2 : Borrow<Foo>>(x : T1, y : T2) -> bool
{
match (*x.borrow(), *y.borrow())
{
(&Foo::Bar, &Foo::Bar) => true,
(&Foo::Baz, &Foo::Baz) => true,
_ => false
}
}
fn tupleRef<T>(myRef: T) -> (T, i32)
where T : Borrow<Foo>
{
return (myRef, 3);
}
fn goodTupleUse() -> ( Box<Foo> , i32)
{
let x = Foo::Bar ;
tupleRef(Box::new(x))
}
fn main() {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment