2013-08-11 12:58:48 -05:00
|
|
|
trait Foo {
|
|
|
|
fn borrowed(&self);
|
|
|
|
fn borrowed_mut(&mut self);
|
|
|
|
}
|
|
|
|
|
2019-05-28 13:46:13 -05:00
|
|
|
fn borrowed_receiver(x: &dyn Foo) {
|
2013-08-11 12:58:48 -05:00
|
|
|
x.borrowed();
|
|
|
|
x.borrowed_mut(); //~ ERROR cannot borrow
|
|
|
|
}
|
|
|
|
|
2019-05-28 13:46:13 -05:00
|
|
|
fn borrowed_mut_receiver(x: &mut dyn Foo) {
|
2013-08-11 12:58:48 -05:00
|
|
|
x.borrowed();
|
|
|
|
x.borrowed_mut();
|
|
|
|
}
|
|
|
|
|
2019-05-28 13:46:13 -05:00
|
|
|
fn owned_receiver(x: Box<dyn Foo>) {
|
2013-08-11 12:58:48 -05:00
|
|
|
x.borrowed();
|
|
|
|
x.borrowed_mut(); //~ ERROR cannot borrow
|
|
|
|
}
|
|
|
|
|
2019-05-28 13:46:13 -05:00
|
|
|
fn mut_owned_receiver(mut x: Box<dyn Foo>) {
|
2013-08-11 12:58:48 -05:00
|
|
|
x.borrowed();
|
|
|
|
x.borrowed_mut();
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {}
|