mirror of
https://github.com/rust-lang/rust
synced 2024-11-05 20:45:15 +00:00
22 lines
378 B
Rust
22 lines
378 B
Rust
use std::ops::Index;
|
|
|
|
struct Test;
|
|
struct Container(Test);
|
|
|
|
impl Test {
|
|
fn test(&mut self) {}
|
|
}
|
|
|
|
impl<'a> Index<&'a bool> for Container {
|
|
type Output = Test;
|
|
|
|
fn index(&self, _index: &'a bool) -> &Test {
|
|
&self.0
|
|
}
|
|
}
|
|
|
|
fn main() {
|
|
let container = Container(Test);
|
|
let mut val = true;
|
|
container[&mut val].test(); //~ ERROR: cannot borrow data
|
|
}
|