1 // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 // Test that we pick which version of `Foo` to run based on whether
12 // the type we (ultimately) inferred for `x` is copyable or not.
14 // In this case, the two versions are both impls of same trait, and
15 // hence we we can resolve method even without knowing yet which
16 // version will run (note that the `push` occurs after the call to
23 impl<T:Copy> Foo for Vec<T> {
24 fn foo(&self) -> int {1}
27 impl<T> Foo for Vec<Box<T>> {
28 fn foo(&self) -> int {2}
31 fn call_foo_copy() -> int {
32 let mut x = Vec::new();
38 fn call_foo_other() -> int {
39 let mut x = Vec::new();
46 assert_eq!(call_foo_copy(), 1);
47 assert_eq!(call_foo_other(), 2);