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