Skip to content

Commit dfb2629

Browse files
committed
---
yaml --- r: 139791 b: refs/heads/try2 c: 27a0269 h: refs/heads/master i: 139789: 0892972 139787: 24ee62a 139783: 934ef13 139775: 2db0e9c v: v3
1 parent de8de75 commit dfb2629

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 2ec2d99bbd1a15a8f278b3cb82ddfa9ebafa96b3
8+
refs/heads/try2: 27a0269501637d7fa27356caa9c13ab66fe5c8b0
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/libstd/base64.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,21 @@ static CHARS: [char, ..64] = [
2626
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/'
2727
];
2828

29+
/**
30+
* Turn a vector of `u8` bytes into a string representing them in base64.
31+
*
32+
* *Example*:
33+
*
34+
* ~~~~
35+
* extern mod std;
36+
* use std::base64::ToBase64;
37+
*
38+
* fn main () {
39+
* let str = [52,32].to_base64();
40+
* println(fmt!("%s", str));
41+
* }
42+
* ~~~~
43+
*/
2944
impl<'self> ToBase64 for &'self [u8] {
3045
fn to_base64(&self) -> ~str {
3146
let mut s = ~"";
@@ -102,6 +117,25 @@ pub trait FromBase64 {
102117
fn from_base64(&self) -> ~[u8];
103118
}
104119
120+
/**
121+
* Turn a vector of `u8`s representing characters
122+
* encoding byte values in base64 into the vector of `u8` byte values.
123+
*
124+
* *Example*:
125+
*
126+
* ~~~~
127+
* extern mod std;
128+
* use std::base64::ToBase64;
129+
* use std::base64::FromBase64;
130+
*
131+
* fn main () {
132+
* let str = [52,32].to_base64();
133+
* println(fmt!("%s", str));
134+
* let bytes = str.from_base64();
135+
* println(fmt!("%?",bytes));
136+
* }
137+
* ~~~~
138+
*/
105139
impl FromBase64 for ~[u8] {
106140
fn from_base64(&self) -> ~[u8] {
107141
if self.len() % 4u != 0u { fail!(~"invalid base64 length"); }

0 commit comments

Comments
 (0)