[SOLVED] Concatening a string which is a member of struct

Hi There

i have a struct:

Struct Foo {
   bar: String 
}

impl Foo {
  fn bar(&self){
    let baz = *&self.bar + "foo" // (the "foo" part isn't important here)
  }
}

I get

cannot move out of borrowed content

for *&self.bar

Is there a way I can get the value so I can concatenate it with foo?
`

let baz = format!("{}foo", self.bar);
3 Likes

Hey thanks for the quick reply. What if "foo" is stored in a variable?

EDIT: Nevamind. i am checking the docs :smiley:

In this case the format would need to take two variables, i.e. 3 params in total.

Yah. Got it working. Thanks :slight_smile: