fork/rust
git clone https://git.julia.blue/fork/rust
3bcad65fbf6
master
1// run-rustfix 2// check-only 3 4#[derive(Debug)] 5struct Demo { 6 a: String 7} 8 9trait GetString { 10 fn get_a(&self) -> &String; 11} 12 13trait UseString: std::fmt::Debug + GetString { 14 fn use_string(&self) { 15 println!("{:?}", self.get_a()); //~ ERROR no method named `get_a` found 16 } 17} 18 19trait UseString2: GetString { 20 fn use_string(&self) { 21 println!("{:?}", self.get_a()); //~ ERROR no method named `get_a` found 22 } 23} 24 25impl GetString for Demo { 26 fn get_a(&self) -> &String { 27 &self.a 28 } 29} 30 31impl UseString for Demo {} 32impl UseString2 for Demo {} 33 34 35#[cfg(test)] 36mod tests { 37 use crate::{Demo, UseString}; 38 39 #[test] 40 fn it_works() { 41 let d = Demo { a: "test".to_string() }; 42 d.use_string(); 43 } 44} 45 46 47fn main() {}