rust - String append, cannot move out of dereference of '&'pointer -


I'm having trouble combining two stars, I'm new in battle so that if there's an easy way to do this Please feel free to show me

A functional string of Tuples (string, string) my function loops through, what I want to do is combine these two string elements in a string here What do I have:

  for bump.bitmap_picture.mut_iter () for tup (and xfarf, ref y) = tup; Let_string = x; Res_string.append (y.as_slice ()); }   

But I got the error: error: for line '& amp; - can not go beyond dereference of pointer : res_string.append (Y.as_slice ());

I also tried res_string.append (y.clone (.) As_slice ()); But the exact same error happened, so I'm not sure that this was also right.

The function definition of the append is:

  FN attached (self, Second: & amp; RR) - & gt; The string   

plain self indicates the sub-word semantic takes the BY-val receiver to the method, unless the receiver does not apply the copy (which is the string No). So you have to clone X instead of Y.

If you want to exit a vector, you have to use the move_iter .

There are probably some other improvements possible:

  String_pier = Wake! [("Foo" .to_ string (), "bar" .to_string ())]; // Option 1: leave the original vector intact wire string = VAC :: new (); For & amp; (Ref x, ref y) in string_pairs.iter ()) string = x.clone (). Append (y.as_slice ()); Strings.push (string); } // Option 2: Use strings to the original vector: Vec & lt; String & gt; = String_pairs.move_iter () .map (| (x, y) | x.append (y.as_slice ())) .collect ();    

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -