about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorLeah Hanson <astrieanna@gmail.com>2013-04-12 22:15:56 -0400
committerLeah Hanson <astrieanna@gmail.com>2013-04-12 22:15:56 -0400
commit27a0269501637d7fa27356caa9c13ab66fe5c8b0 (patch)
treec0702774578a5c0686e777b13fab70f9ec9fc769 /src/libstd
parent2ec2d99bbd1a15a8f278b3cb82ddfa9ebafa96b3 (diff)
downloadrust-27a0269501637d7fa27356caa9c13ab66fe5c8b0.tar.gz
rust-27a0269501637d7fa27356caa9c13ab66fe5c8b0.zip
Add comments for the implementations of from_base64 and to_base64 for .
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/base64.rs34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/libstd/base64.rs b/src/libstd/base64.rs
index 0815e0ff0b5..618f5ecccf7 100644
--- a/src/libstd/base64.rs
+++ b/src/libstd/base64.rs
@@ -26,6 +26,21 @@ static CHARS: [char, ..64] = [
     '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/'
 ];
 
+/**
+ * Turn a vector of `u8` bytes into a string representing them in base64.
+ *
+ * *Example*:
+ *
+ * ~~~~
+ * extern mod std;
+ * use std::base64::ToBase64;
+ *
+ * fn main () {
+ *   let str = [52,32].to_base64();
+ *   println(fmt!("%s", str));
+ * }
+ * ~~~~
+ */
 impl<'self> ToBase64 for &'self [u8] {
     fn to_base64(&self) -> ~str {
         let mut s = ~"";
@@ -102,6 +117,25 @@ pub trait FromBase64 {
     fn from_base64(&self) -> ~[u8];
 }
 
+/**
+ * Turn a vector of `u8`s representing characters
+ * encoding byte values in base64 into the vector of `u8` byte values.
+ *
+ * *Example*:
+ *
+ * ~~~~
+ * extern mod std;
+ * use std::base64::ToBase64;
+ * use std::base64::FromBase64;
+ *
+ * fn main () {
+ *   let str = [52,32].to_base64();
+ *   println(fmt!("%s", str));
+ *   let bytes = str.from_base64();
+ *   println(fmt!("%?",bytes));
+ * }
+ * ~~~~
+ */
 impl FromBase64 for ~[u8] {
     fn from_base64(&self) -> ~[u8] {
         if self.len() % 4u != 0u { fail!(~"invalid base64 length"); }