anchor.diff:  = Rust Strings, Explained
   :hp-tags: rust
   
  -== Introduction to &str and String
   
  -Rust has two main types of strings: `&str` and `String`.
  +Rust has two main types of strings: `&str` and `String`.  
  +
  +In the following code sample, the string `addr`, also known as a 'string slice', is statically allocated, meaning that it’s saved inside our compiled program, and exists for the entire duration it runs. The greeting binding is a reference to this statically allocated string. String slices have a fixed size, and cannot be mutated.
  +
  +A `String` like `addr_str`, on the other hand, is a heap-allocated string. This string is growable, and is also guaranteed to be UTF-8. Strings are commonly created by converting from a string slice using the `to_string` method.
  +
  +To coerce a `String` into a `&str`, you can use `&`, unless the destination type is a trait of &str, in which case you need to use `&*`.
   
   [code,rust]
   ----
  
positive.code: TcpStream::connect(addr); // no problem
  TcpStream::connect(&*addr_string); // no automatic coercion to traits of &str
  ----
  
  This string `addr`, also known as a 'string slice', is statically allocated, meaning that it’s saved inside our compiled program, and exists for the entire duration it runs. The greeting binding is a reference to this statically allocated string. String slices have a fixed size, and cannot be mutated.
  
  A `String` like `addr_str`, on the other hand, is a heap-allocated string. This string is growable, and is also guaranteed to be UTF-8. Strings are commonly created by converting from a string slice using the `to_string` method.
  
  To coerce a `String` into a `&str`, you can use `&`, unless the destination type is a trait of &str, in which case you need to use `&*`.
  
  
  == Should I use a String, a &str, or one of the traits of &str?
  
negative.code: 
  Unfortunately, `collect()` returns a link:https://doc.rust-lang.org/std/iter/trait.FromIterator.html[std:iter::FromIterator], which by itself has no useful methods.  We have to just **know** that the underlying implementor is link:https://doc.rust-lang.org/collections/vec/struct.Vec.html[collections::Vec], and as uncomfortable as this kind of manual type coercion might be, it seems very unlikely to change.
  
  === Slice patterns
  
  What about the better way, the way of the future?  Actually there are two improvements coming, and the first involves an unstable feature called link:https://doc.rust-lang.org/book/slice-patterns.html[Slice Patterns].
  
  [code,rust]
  ----
  