2023-01-03 13:27:49 +08:00
|
|
|
#[derive(Clone)]
|
|
|
|
struct S;
|
|
|
|
|
|
|
|
trait X {}
|
|
|
|
|
|
|
|
impl X for S {}
|
|
|
|
|
|
|
|
fn foo<T: X>(_: T) {}
|
2023-01-07 07:16:48 +08:00
|
|
|
fn bar<T: X>(s: &T) {
|
2023-01-03 13:27:49 +08:00
|
|
|
foo(s); //~ ERROR the trait bound `&T: X` is not satisfied
|
|
|
|
}
|
|
|
|
|
2023-01-07 07:16:48 +08:00
|
|
|
fn bar_with_clone<T: X + Clone>(s: &T) {
|
2023-01-03 13:27:49 +08:00
|
|
|
foo(s); //~ ERROR the trait bound `&T: X` is not satisfied
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let s = &S;
|
|
|
|
bar(s);
|
|
|
|
}
|