mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-02 19:53:46 +00:00
24 lines
380 B
Rust
24 lines
380 B
Rust
use std::ops::Deref;
|
|
|
|
struct Container {
|
|
target: Vec<()>,
|
|
container_field: bool,
|
|
}
|
|
|
|
impl Deref for Container {
|
|
type Target = [()];
|
|
fn deref(&self) -> &Self::Target {
|
|
&self.target
|
|
}
|
|
}
|
|
|
|
impl Container {
|
|
fn bad_borrow(&mut self) {
|
|
let first = &self[0];
|
|
self.container_field = true; //~ ERROR E0506
|
|
first;
|
|
}
|
|
}
|
|
|
|
fn main() {}
|