1 // Copyright 2015 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 // aux-build:specialization_cross_crate.rs
13 #![feature(specialization)]
15 extern crate specialization_cross_crate;
17 use specialization_cross_crate::*;
22 struct MarkedAndClone;
23 impl MyMarker for MarkedAndClone {}
26 default impl<T> Foo for MyType<T> {
27 fn foo(&self) -> &'static str {
32 impl Foo for MyType<u8> {
33 fn foo(&self) -> &'static str {
39 impl Foo for MyOtherType {}
42 assert!(NotClone.foo() == "generic");
43 assert!(0u8.foo() == "generic Clone");
44 assert!(vec![NotClone].foo() == "generic");
45 assert!(vec![0u8].foo() == "generic Vec");
46 assert!(vec![0i32].foo() == "Vec<i32>");
47 assert!(0i32.foo() == "i32");
48 assert!(String::new().foo() == "String");
49 assert!(((), 0).foo() == "generic pair");
50 assert!(((), ()).foo() == "generic uniform pair");
51 assert!((0u8, 0u32).foo() == "(u8, u32)");
52 assert!((0u8, 0u8).foo() == "(u8, u8)");
53 assert!(MarkedAndClone.foo() == "generic Clone + MyMarker");
55 assert!(MyType(()).foo() == "generic MyType");
56 assert!(MyType(0u8).foo() == "MyType<u8>");
57 assert!(MyOtherType.foo() == "generic");