2016-11-08 09:21:53 +03:00
|
|
|
trait B {
|
|
|
|
fn foo(mut a: &String) {
|
2019-04-22 08:40:08 +01:00
|
|
|
a.push_str("bar"); //~ ERROR cannot borrow `*a` as mutable, as it is behind a `&` reference
|
2016-11-08 09:21:53 +03:00
|
|
|
}
|
2012-09-11 21:25:01 -07:00
|
|
|
}
|
|
|
|
|
2016-11-08 09:21:53 +03:00
|
|
|
pub fn foo<'a>(mut a: &'a String) {
|
2019-04-22 08:40:08 +01:00
|
|
|
a.push_str("foo"); //~ ERROR cannot borrow `*a` as mutable, as it is behind a `&` reference
|
2012-09-11 21:25:01 -07:00
|
|
|
}
|
|
|
|
|
2016-11-08 09:21:53 +03:00
|
|
|
struct A {}
|
2012-09-11 21:25:01 -07:00
|
|
|
|
2016-11-08 09:21:53 +03:00
|
|
|
impl A {
|
|
|
|
pub fn foo(mut a: &String) {
|
2019-04-22 08:40:08 +01:00
|
|
|
a.push_str("foo"); //~ ERROR cannot borrow `*a` as mutable, as it is behind a `&` reference
|
2016-11-08 09:21:53 +03:00
|
|
|
}
|
2012-09-11 21:25:01 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
2016-11-08 09:21:53 +03:00
|
|
|
foo(&"a".to_string());
|
|
|
|
A::foo(&"a".to_string());
|
2012-09-11 21:25:01 -07:00
|
|
|
}
|