diff options
| author | bors <bors@rust-lang.org> | 2013-05-29 08:49:53 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-05-29 08:49:53 -0700 |
| commit | a037fa4da3ce71d23e27d62485cc5d0f6280ed58 (patch) | |
| tree | a4946edd61d9cbed35ebd941ee6e41a6a9a042e2 | |
| parent | 844b5cff363cdb4ca2baa9152263a5f14a0dcdb0 (diff) | |
| parent | b1e7d49b11a51fb3d6b41c0ec677d0d40e1d2c26 (diff) | |
| download | rust-a037fa4da3ce71d23e27d62485cc5d0f6280ed58.tar.gz rust-a037fa4da3ce71d23e27d62485cc5d0f6280ed58.zip | |
auto merge of #6796 : sfackler/rust/FromBase64-type-fix, r=bstrie
Previously, FromBase64 was only implemented on ~[u8] and ~str when any pointer would do. The implementations of FromBase64 are now consistent with the implementations of ToBase64.
| -rw-r--r-- | src/libextra/base64.rs | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/src/libextra/base64.rs b/src/libextra/base64.rs index e06bf284482..7829eb50a68 100644 --- a/src/libextra/base64.rs +++ b/src/libextra/base64.rs @@ -113,7 +113,7 @@ pub trait FromBase64 { fn from_base64(&self) -> ~[u8]; } -impl FromBase64 for ~[u8] { +impl<'self> FromBase64 for &'self [u8] { /** * Convert base64 `u8` vector into u8 byte values. * Every 4 encoded characters is converted into 3 octets, modulo padding. @@ -188,7 +188,7 @@ impl FromBase64 for ~[u8] { } } -impl FromBase64 for ~str { +impl<'self> FromBase64 for &'self str { /** * Convert any base64 encoded string (literal, `@`, `&`, or `~`) * to the byte values it encodes. @@ -227,23 +227,23 @@ mod tests { #[test] fn test_to_base64() { - assert_eq!((~"").to_base64(), ~""); - assert!((~"f").to_base64() == ~"Zg=="); - assert_eq!((~"fo").to_base64(), ~"Zm8="); - assert_eq!((~"foo").to_base64(), ~"Zm9v"); - assert!((~"foob").to_base64() == ~"Zm9vYg=="); - assert_eq!((~"fooba").to_base64(), ~"Zm9vYmE="); - assert_eq!((~"foobar").to_base64(), ~"Zm9vYmFy"); + assert_eq!("".to_base64(), ~""); + assert_eq!("f".to_base64(), ~"Zg=="); + assert_eq!("fo".to_base64(), ~"Zm8="); + assert_eq!("foo".to_base64(), ~"Zm9v"); + assert_eq!("foob".to_base64(), ~"Zm9vYg=="); + assert_eq!("fooba".to_base64(), ~"Zm9vYmE="); + assert_eq!("foobar".to_base64(), ~"Zm9vYmFy"); } #[test] fn test_from_base64() { - assert_eq!((~"").from_base64(), str::to_bytes("")); - assert!((~"Zg==").from_base64() == str::to_bytes("f")); - assert_eq!((~"Zm8=").from_base64(), str::to_bytes("fo")); - assert_eq!((~"Zm9v").from_base64(), str::to_bytes("foo")); - assert!((~"Zm9vYg==").from_base64() == str::to_bytes("foob")); - assert_eq!((~"Zm9vYmE=").from_base64(), str::to_bytes("fooba")) - assert_eq!((~"Zm9vYmFy").from_base64(), str::to_bytes("foobar")); + assert_eq!("".from_base64(), str::to_bytes("")); + assert_eq!("Zg==".from_base64(), str::to_bytes("f")); + assert_eq!("Zm8=".from_base64(), str::to_bytes("fo")); + assert_eq!("Zm9v".from_base64(), str::to_bytes("foo")); + assert_eq!("Zm9vYg==".from_base64(), str::to_bytes("foob")); + assert_eq!("Zm9vYmE=".from_base64(), str::to_bytes("fooba")) + assert_eq!("Zm9vYmFy".from_base64(), str::to_bytes("foobar")); } } |
