mirror of
https://github.com/rust-lang/rust
synced 2024-11-05 20:45:15 +00:00
26 lines
466 B
Rust
26 lines
466 B
Rust
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() {}
|