Skip to content

Instantly share code, notes, and snippets.

@SiegeLord
Last active August 29, 2015 13:57
Show Gist options
  • Select an option

  • Save SiegeLord/9497895 to your computer and use it in GitHub Desktop.

Select an option

Save SiegeLord/9497895 to your computer and use it in GitHub Desktop.
Arrays
struct MyArray<T>(~[T]);
trait Foo {}
struct A;
impl Foo for A {}
struct B;
impl Foo for B {}
impl<T: Foo> Foo for MyArray<T> {}
fn test(a: &Foo)
{
}
fn main()
{
let a = MyArray(~[A]);
let b = MyArray(~[B]);
let ao = &a as &Foo;
let bo = &b as &Foo;
test(ao);
test(bo);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment