mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-02 19:53:46 +00:00
34 lines
475 B
Rust
34 lines
475 B
Rust
use std::ops::Deref;
|
|
|
|
struct NotCopy {
|
|
inner: bool
|
|
}
|
|
|
|
impl NotCopy {
|
|
fn inner_method(&self) {}
|
|
}
|
|
|
|
struct Foo {
|
|
first: NotCopy,
|
|
second: NotCopy
|
|
}
|
|
|
|
impl Deref for Foo {
|
|
type Target = NotCopy;
|
|
fn deref(&self) -> &NotCopy {
|
|
&self.second
|
|
}
|
|
}
|
|
|
|
fn use_field(val: Foo) {
|
|
let _val = val.first;
|
|
val.inner; //~ ERROR borrow of
|
|
}
|
|
|
|
fn use_method(val: Foo) {
|
|
let _val = val.first;
|
|
val.inner_method(); //~ ERROR borrow of
|
|
}
|
|
|
|
fn main() {}
|