From bed34ecd08423007548c8f3bc126b4c6dca5b4b4 Mon Sep 17 00:00:00 2001
From: WebeWizard <webewizard@gmail.com>
Date: Tue, 11 Feb 2014 15:49:06 -0600
Subject: [PATCH] Added examples for converting vectors of u8 into strings.
 Also fixed some styling

---
 src/doc/complement-cheatsheet.md | 34 ++++++++++++++++++++++++++++++--
 1 file changed, 32 insertions(+), 2 deletions(-)

diff --git a/src/doc/complement-cheatsheet.md b/src/doc/complement-cheatsheet.md
index a92980d5e70..a2d75fc95d1 100644
--- a/src/doc/complement-cheatsheet.md
+++ b/src/doc/complement-cheatsheet.md
@@ -36,12 +36,42 @@ let y: ~str = x.to_str_radix(16);
 Use [`FromStrRadix`](http://static.rust-lang.org/doc/master/std/num/trait.FromStrRadix.html), and its helper function, [`from_str_radix`](http://static.rust-lang.org/doc/master/std/num/fn.from_str_radix.html).
 
 ~~~
-use std::num::from_str_radix;
+use std::num;
 
-let x: Option<i64> = from_str_radix("deadbeef", 16);
+let x: Option<i64> = num::from_str_radix("deadbeef", 16);
 let y: i64 = x.unwrap();
 ~~~
 
+**Vector of Bytes to String**
+
+To return a Borrowed String Slice (&str) use the str helper function [`from_utf8`](http://static.rust-lang.org/doc/master/std/str/fn.from_utf8.html).
+
+~~~
+use std::str;
+
+let bytes = ~[104u8,105u8];
+let x: Option<&str> = str::from_utf8(bytes);
+let y: &str = x.unwrap();
+~~~
+
+To return an Owned String (~str) use the str helper function [`from_utf8_owned`](http://static.rust-lang.org/doc/master/std/str/fn.from_utf8_owned.html).
+
+~~~
+use std::str;
+
+let x: Option<~str> = str::from_utf8_owned(~[104u8,105u8]);
+let y: ~str = x.unwrap();
+~~~~
+
+To return a [`MaybeOwned`](http://static.rust-lang.org/doc/master/std/str/enum.MaybeOwned.html) use the str helper function [`from_utf8_lossy`](http://static.rust-lang.org/doc/master/std/str/fn.from_utf8_owned.html).  This function also replaces non-valid utf-8 sequences with U+FFFD replacement character.
+
+~~~
+use std::str;
+
+let x = bytes!(72u8,"ello ",0xF0,0x90,0x80,"World!");
+let y = str::from_utf8_lossy(x);
+~~~~
+
 # File operations
 
 ## How do I read from a file?