Last active
October 19, 2016 20:21
-
-
Save JoeyEremondi/63ebd1b19a3c73d8c01c6393ecf5344b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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