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