1 // Copyright 2014 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 can use method notation to call methods based on a
12 // projection bound from a trait. Issue #20469.
14 ///////////////////////////////////////////////////////////////////////////
18 fn make_string(&self) -> String;
21 impl MakeString for isize {
22 fn make_string(&self) -> String {
27 impl MakeString for usize {
28 fn make_string(&self) -> String {
33 ///////////////////////////////////////////////////////////////////////////
38 fn get(&self) -> &Self::F;
41 fn foo<F:Foo>(f: &F) -> String {
45 ///////////////////////////////////////////////////////////////////////////
51 impl Foo for SomeStruct {
54 fn get(&self) -> &isize {
59 ///////////////////////////////////////////////////////////////////////////
61 struct SomeOtherStruct {
65 impl Foo for SomeOtherStruct {
68 fn get(&self) -> &usize {
74 let x = SomeStruct { field: 22 };
75 assert_eq!(foo(&x), format!("22"));
77 let x = SomeOtherStruct { field: 44 };
78 assert_eq!(foo(&x), format!("44"));