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