@@ -113,7 +113,7 @@ pub trait FromBase64 {
113
113
fn from_base64 ( & self ) -> ~[ u8 ] ;
114
114
}
115
115
116
- impl FromBase64 for ~ [ u8 ] {
116
+ impl < ' self > FromBase64 for & ' self [ u8 ] {
117
117
/**
118
118
* Convert base64 `u8` vector into u8 byte values.
119
119
* Every 4 encoded characters is converted into 3 octets, modulo padding.
@@ -188,7 +188,7 @@ impl FromBase64 for ~[u8] {
188
188
}
189
189
}
190
190
191
- impl FromBase64 for ~ str {
191
+ impl < ' self > FromBase64 for & ' self str {
192
192
/**
193
193
* Convert any base64 encoded string (literal, `@`, `&`, or `~`)
194
194
* to the byte values it encodes.
@@ -227,23 +227,23 @@ mod tests {
227
227
228
228
#[ test]
229
229
fn test_to_base64( ) {
230
- assert_eq ! ( ( ~"" ) . to_base64( ) , ~"") ;
231
- assert ! ( ( ~ "f") .to_base64() == ~" Zg ==");
232
- assert_eq!((~ " fo") .to_base64(), ~" Zm8 =");
233
- assert_eq!((~ " foo") .to_base64(), ~" Zm9v ");
234
- assert!((~ " foob") .to_base64() == ~" Zm9vYg ==");
235
- assert_eq!((~ " fooba") .to_base64(), ~" Zm9vYmE =");
236
- assert_eq!((~ " foobar") .to_base64(), ~" Zm9vYmFy ");
230
+ assert_eq!( "" . to_base64( ) , ~"") ;
231
+ assert_eq! ( "f". to_base64( ) , ~"Zg ==") ;
232
+ assert_eq!( "fo". to_base64( ) , ~"Zm8 =") ;
233
+ assert_eq!( "foo". to_base64( ) , ~"Zm9v ") ;
234
+ assert_eq! ( "foob". to_base64( ) , ~"Zm9vYg ==") ;
235
+ assert_eq!( "fooba". to_base64( ) , ~"Zm9vYmE =") ;
236
+ assert_eq!( "foobar". to_base64( ) , ~"Zm9vYmFy") ;
237
237
}
238
238
239
239
#[ test]
240
240
fn test_from_base64( ) {
241
- assert_eq!((~" ") .from_base64(), str::to_bytes(""));
242
- assert!((~ " Zg ==") .from_base64() == str::to_bytes(" f"));
243
- assert_eq!((~ " Zm8 =") .from_base64(), str::to_bytes(" fo"));
244
- assert_eq!((~ " Zm9v ") .from_base64(), str::to_bytes(" foo"));
245
- assert!((~ " Zm9vYg ==") .from_base64() == str::to_bytes(" foob"));
246
- assert_eq!((~ " Zm9vYmE =") .from_base64(), str::to_bytes(" fooba"))
247
- assert_eq!((~ " Zm9vYmFy ") .from_base64(), str::to_bytes(" foobar" ) ) ;
241
+ assert_eq ! ( "" . from_base64( ) , str :: to_bytes( "" ) ) ;
242
+ assert_eq ! ( "Zg==" . from_base64( ) , str :: to_bytes( "f" ) ) ;
243
+ assert_eq ! ( "Zm8=" . from_base64( ) , str :: to_bytes( "fo" ) ) ;
244
+ assert_eq ! ( "Zm9v" . from_base64( ) , str :: to_bytes( "foo" ) ) ;
245
+ assert_eq ! ( "Zm9vYg==" . from_base64( ) , str :: to_bytes( "foob" ) ) ;
246
+ assert_eq!( "Zm9vYmE=" . from_base64( ) , str :: to_bytes( "fooba" ) )
247
+ assert_eq!( "Zm9vYmFy" . from_base64( ) , str :: to_bytes( "foobar" ) ) ;
248
248
}
249
249
}
0 commit comments