Skip to content
This repository was archived by the owner on Dec 1, 2023. It is now read-only.

Commit 2cb0aae

Browse files
committed
Update to master
1 parent e8a3aea commit 2cb0aae

File tree

6 files changed

+105
-89
lines changed

6 files changed

+105
-89
lines changed

src/base64.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,13 @@ impl ToBase64 for [u8] {
8282
/// # Example
8383
///
8484
/// ```rust
85-
/// extern crate serialize;
86-
/// use serialize::base64::{ToBase64, STANDARD};
85+
/// # #![allow(staged_unstable)]
86+
/// extern crate "rustc-serialize" as rustc_serialize;
87+
/// use rustc_serialize::base64::{ToBase64, STANDARD};
8788
///
8889
/// fn main () {
8990
/// let str = [52,32].to_base64(STANDARD);
90-
/// println!("base 64 output: {}", str);
91+
/// println!("base 64 output: {:?}", str);
9192
/// }
9293
/// ```
9394
fn to_base64(&self, config: Config) -> String {
@@ -204,7 +205,7 @@ impl error::Error for FromBase64Error {
204205
}
205206

206207
fn detail(&self) -> Option<String> {
207-
Some(self.to_string())
208+
Some(format!("{:?}", self))
208209
}
209210
}
210211

@@ -220,8 +221,10 @@ impl FromBase64 for str {
220221
/// This converts a string literal to base64 and back.
221222
///
222223
/// ```rust
223-
/// extern crate serialize;
224-
/// use serialize::base64::{ToBase64, FromBase64, STANDARD};
224+
/// # #![allow(staged_unstable)]
225+
/// # #![allow(staged_experimental)]
226+
/// extern crate "rustc-serialize" as rustc_serialize;
227+
/// use rustc_serialize::base64::{ToBase64, FromBase64, STANDARD};
225228
///
226229
/// fn main () {
227230
/// let hello_str = b"Hello, World".to_base64(STANDARD);
@@ -230,7 +233,7 @@ impl FromBase64 for str {
230233
/// if res.is_ok() {
231234
/// let opt_bytes = String::from_utf8(res.unwrap());
232235
/// if opt_bytes.is_ok() {
233-
/// println!("decoded from base64: {}", opt_bytes.unwrap());
236+
/// println!("decoded from base64: {:?}", opt_bytes.unwrap());
234237
/// }
235238
/// }
236239
/// }

src/collection_impls.rs

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use std::hash::{Hash, Hasher};
1515

1616
use {Decodable, Encodable, Decoder, Encoder};
1717
use std::collections::{DList, RingBuf, BTreeMap, BTreeSet, HashMap, HashSet, VecMap};
18+
use std::collections::hash_state::HashState;
1819

1920
impl<
2021
T: Encodable
@@ -127,13 +128,13 @@ impl<
127128
}
128129
}
129130

130-
impl<
131-
K: Encodable + Hash<X> + Eq,
132-
V: Encodable,
133-
X,
134-
H: Hasher<X>
135-
> Encodable for HashMap<K, V, H> {
136-
fn encode<S: Encoder>(&self, e: &mut S) -> Result<(), S::Error> {
131+
impl<K, V, S> Encodable for HashMap<K, V, S>
132+
where K: Encodable + Hash< <S as HashState>::Hasher> + Eq,
133+
V: Encodable,
134+
S: HashState,
135+
<S as HashState>::Hasher: Hasher<Output=u64>
136+
{
137+
fn encode<E: Encoder>(&self, e: &mut E) -> Result<(), E::Error> {
137138
e.emit_map(self.len(), |e| {
138139
let mut i = 0;
139140
for (key, val) in self.iter() {
@@ -146,16 +147,16 @@ impl<
146147
}
147148
}
148149

149-
impl<
150-
K: Decodable + Hash<S> + Eq,
151-
V: Decodable,
152-
S,
153-
H: Hasher<S> + Default
154-
> Decodable for HashMap<K, V, H> {
155-
fn decode<D: Decoder>(d: &mut D) -> Result<HashMap<K, V, H>, D::Error> {
150+
impl<K, V, S> Decodable for HashMap<K, V, S>
151+
where K: Decodable + Hash< <S as HashState>::Hasher> + Eq,
152+
V: Decodable,
153+
S: HashState + Default,
154+
<S as HashState>::Hasher: Hasher<Output=u64>
155+
{
156+
fn decode<D: Decoder>(d: &mut D) -> Result<HashMap<K, V, S>, D::Error> {
156157
d.read_map(|d, len| {
157-
let hasher = Default::default();
158-
let mut map = HashMap::with_capacity_and_hasher(len, hasher);
158+
let state = Default::default();
159+
let mut map = HashMap::with_capacity_and_hash_state(len, state);
159160
for i in range(0u, len) {
160161
let key = try!(d.read_map_elt_key(i, |d| Decodable::decode(d)));
161162
let val = try!(d.read_map_elt_val(i, |d| Decodable::decode(d)));
@@ -166,12 +167,12 @@ impl<
166167
}
167168
}
168169

169-
impl<
170-
T: Encodable + Hash<X> + Eq,
171-
X,
172-
H: Hasher<X>
173-
> Encodable for HashSet<T, H> {
174-
fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> {
170+
impl<T, S> Encodable for HashSet<T, S>
171+
where T: Encodable + Hash< <S as HashState>::Hasher> + Eq,
172+
S: HashState,
173+
<S as HashState>::Hasher: Hasher<Output=u64>
174+
{
175+
fn encode<E: Encoder>(&self, s: &mut E) -> Result<(), E::Error> {
175176
s.emit_seq(self.len(), |s| {
176177
let mut i = 0;
177178
for e in self.iter() {
@@ -183,22 +184,22 @@ impl<
183184
}
184185
}
185186

186-
impl<
187-
T: Decodable + Hash<S> + Eq,
188-
S,
189-
H: Hasher<S> + Default
190-
> Decodable for HashSet<T, H> {
191-
fn decode<D: Decoder>(d: &mut D) -> Result<HashSet<T, H>, D::Error> {
187+
impl<T, S> Decodable for HashSet<T, S>
188+
where T: Decodable + Hash< <S as HashState>::Hasher> + Eq,
189+
S: HashState + Default,
190+
<S as HashState>::Hasher: Hasher<Output=u64>
191+
{
192+
fn decode<D: Decoder>(d: &mut D) -> Result<HashSet<T, S>, D::Error> {
192193
d.read_seq(|d, len| {
193-
let mut set = HashSet::with_capacity_and_hasher(len, Default::default());
194+
let state = Default::default();
195+
let mut set = HashSet::with_capacity_and_hash_state(len, state);
194196
for i in range(0u, len) {
195197
set.insert(try!(d.read_seq_elt(i, |d| Decodable::decode(d))));
196198
}
197199
Ok(set)
198200
})
199201
}
200202
}
201-
202203
impl<V: Encodable> Encodable for VecMap<V> {
203204
fn encode<S: Encoder>(&self, e: &mut S) -> Result<(), S::Error> {
204205
e.emit_map(self.len(), |e| {

src/hex.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@ impl ToHex for [u8] {
3232
/// # Example
3333
///
3434
/// ```rust
35-
/// extern crate serialize;
36-
/// use serialize::hex::ToHex;
35+
/// # #![allow(staged_unstable)]
36+
/// extern crate "rustc-serialize" as rustc_serialize;
37+
/// use rustc_serialize::hex::ToHex;
3738
///
3839
/// fn main () {
3940
/// let str = [52,32].to_hex();
@@ -88,7 +89,7 @@ impl error::Error for FromHexError {
8889
}
8990

9091
fn detail(&self) -> Option<String> {
91-
Some(self.to_string())
92+
Some(format!("{:?}", self))
9293
}
9394
}
9495

@@ -105,14 +106,15 @@ impl FromHex for str {
105106
/// This converts a string literal to hexadecimal and back.
106107
///
107108
/// ```rust
108-
/// extern crate serialize;
109-
/// use serialize::hex::{FromHex, ToHex};
109+
/// # #![allow(staged_unstable)]
110+
/// extern crate "rustc-serialize" as rustc_serialize;
111+
/// use rustc_serialize::hex::{FromHex, ToHex};
110112
///
111113
/// fn main () {
112114
/// let hello_str = "Hello, World".as_bytes().to_hex();
113115
/// println!("{}", hello_str);
114116
/// let bytes = hello_str.as_slice().from_hex().unwrap();
115-
/// println!("{}", bytes);
117+
/// println!("{:?}", bytes);
116118
/// let result_str = String::from_utf8(bytes).unwrap();
117119
/// println!("{}", result_str);
118120
/// }

0 commit comments

Comments
 (0)