mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-09 07:04:02 +00:00
22 lines
319 B
Rust
22 lines
319 B
Rust
struct Pass<'a> {
|
|
s: &'a mut String
|
|
}
|
|
|
|
impl<'a> Pass<'a> {
|
|
fn f(&mut self) {
|
|
self.s.push('x');
|
|
}
|
|
}
|
|
|
|
struct Foo<'a> {
|
|
s: &'a mut String
|
|
}
|
|
|
|
impl<'a> Foo<'a> {
|
|
fn f(&self) {
|
|
self.s.push('x'); //~ cannot borrow `*self.s` as mutable, as it is behind a `&` reference
|
|
}
|
|
}
|
|
|
|
fn main() {}
|