blob: f5adc2cc1413e7e9e0b81e3287b758f600a15780 (
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
|
trait Foo {
fn borrowed(&self);
fn borrowed_mut(&mut self);
}
fn borrowed_receiver(x: &dyn Foo) {
x.borrowed();
x.borrowed_mut(); //~ ERROR cannot borrow
}
fn borrowed_mut_receiver(x: &mut dyn Foo) {
x.borrowed();
x.borrowed_mut();
}
fn owned_receiver(x: Box<dyn Foo>) {
x.borrowed();
x.borrowed_mut(); //~ ERROR cannot borrow
}
fn mut_owned_receiver(mut x: Box<dyn Foo>) {
x.borrowed();
x.borrowed_mut();
}
fn main() {}
|