title: Appending a char to a string in rust
body: <p>The documentation <a href="http://static.rust-lang.org/doc/0.10/std/str/trait.OwnedStr.html" rel="nofollow">here</a> defines a trait which, among other things, has a method <code>push_char</code> which takes a mutable <code>self</code> and appends a character to it. However, this code fails:</p>
  
  <pre><code>fn foo() {
    let mut s = "hey".to_owned();
    s.push_char('!');
  }
  </code></pre>
  
  <p>Attempting to compile this:</p>
  
  <pre><code>$ rustc --version
  rustc 0.11-pre (e8053b9 2014-05-12 09:12:04 -0700)
  host: x86_64-apple-darwin
  $ rustc appendchar.rs
  appendchar.rs:5:5: 5:19 error: type `~str` does not implement any method in scope named `push_char`
  appendchar.rs:5   s.push_char('!');
                      ^~~~~~~~~~~~~~
  error: aborting due to previous error
  </code></pre>
  
  <p>So we can see that <code>s</code> is indeed of type <code>~str</code>, and according to the docs, this type implements <code>OwnedStr</code>. So why does this fail? By the way, adding the following line doesn't solve it:</p>
  
  <pre><code>use std::str::OwnedStr;
  </code></pre>