about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-10-09 10:41:31 -0700
committerbors <bors@rust-lang.org>2013-10-09 10:41:31 -0700
commit62812f1e38f438dfc666cd9d164b4377063f8794 (patch)
tree14c877c843fe71f1aa15a10ab7cb43b76027ab24
parent4fd7f852e131ad8c9935fd9577c071be5b4635ec (diff)
parent0b4f052422829106b0aadb3b66af671b4e0a0c99 (diff)
downloadrust-62812f1e38f438dfc666cd9d164b4377063f8794.tar.gz
rust-62812f1e38f438dfc666cd9d164b4377063f8794.zip
auto merge of #9386 : Geal/rust/base64-doc, r=alexcrichton
Standard is now uppercase in the base64 module, and from_base64 now returns a Result
-rw-r--r--src/libextra/base64.rs23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/libextra/base64.rs b/src/libextra/base64.rs
index 2b18c27f560..5d9c38c9543 100644
--- a/src/libextra/base64.rs
+++ b/src/libextra/base64.rs
@@ -64,11 +64,11 @@ impl<'self> ToBase64 for &'self [u8] {
      *
      * ```rust
      * extern mod extra;
-     * use extra::base64::{ToBase64, standard};
+     * use extra::base64::{ToBase64, STANDARD};
      *
      * fn main () {
-     *     let str = [52,32].to_base64(standard);
-     *     println!("{}", str);
+     *     let str = [52,32].to_base64(STANDARD);
+     *     println!("base 64 output: {}", str);
      * }
      * ```
      */
@@ -172,16 +172,19 @@ impl<'self> FromBase64 for &'self str {
      *
      * ```rust
      * extern mod extra;
-     * use extra::base64::{ToBase64, FromBase64, standard};
+     * use extra::base64::{ToBase64, FromBase64, STANDARD};
      * use std::str;
      *
      * fn main () {
-     *     let hello_str = "Hello, World".to_base64(standard);
-     *     println!("{}", hello_str);
-     *     let bytes = hello_str.from_base64();
-     *     println!("{:?}", bytes);
-     *     let result_str = str::from_utf8(bytes);
-     *     println!("{}", result_str);
+     *     let hello_str = bytes!("Hello, World").to_base64(STANDARD);
+     *     println!("base64 output: {}", hello_str);
+     *     let res = hello_str.from_base64();
+     *     if res.is_ok() {
+     *       let optBytes = str::from_utf8_opt(res.unwrap());
+     *       if optBytes.is_some() {
+     *         println!("decoded from base64: {}", optBytes.unwrap());
+     *       }
+     *     }
      * }
      * ```
      */