Skip to content

Commit e35eed9

Browse files
committed
---
yaml --- r: 112892 b: refs/heads/auto c: fb72d7c h: refs/heads/master v: v3
1 parent 6c4e219 commit e35eed9

File tree

4 files changed

+39
-39
lines changed

4 files changed

+39
-39
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1313
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1414
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1515
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
16-
refs/heads/auto: b537028116c8f5d98ec6e522ba5fe44067d7234e
16+
refs/heads/auto: fb72d7cfea9ba44581f708b13aa82ab23ee4fa7e
1717
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1818
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1919
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/src/doc/tutorial.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1197,7 +1197,7 @@ fn eq(xs: &List, ys: &List) -> bool {
11971197
match (xs, ys) {
11981198
// If we have reached the end of both lists, they are equal.
11991199
(&Nil, &Nil) => true,
1200-
// If the current element in both lists is equal, keep going.
1200+
// If the current elements of both lists are equal, keep going.
12011201
(&Cons(x, ~ref next_xs), &Cons(y, ~ref next_ys))
12021202
if x == y => eq(next_xs, next_ys),
12031203
// If the current elements are not equal, the lists are not equal.
@@ -1304,7 +1304,7 @@ fn eq<T: Eq>(xs: &List<T>, ys: &List<T>) -> bool {
13041304
match (xs, ys) {
13051305
// If we have reached the end of both lists, they are equal.
13061306
(&Nil, &Nil) => true,
1307-
// If the current element in both lists is equal, keep going.
1307+
// If the current elements of both lists are equal, keep going.
13081308
(&Cons(ref x, ~ref next_xs), &Cons(ref y, ~ref next_ys))
13091309
if x == y => eq(next_xs, next_ys),
13101310
// If the current elements are not equal, the lists are not equal.
@@ -1333,7 +1333,7 @@ impl<T: Eq> Eq for List<T> {
13331333
match (self, ys) {
13341334
// If we have reached the end of both lists, they are equal.
13351335
(&Nil, &Nil) => true,
1336-
// If the current element in both lists is equal, keep going.
1336+
// If the current elements of both lists are equal, keep going.
13371337
(&Cons(ref x, ~ref next_xs), &Cons(ref y, ~ref next_ys))
13381338
if x == y => next_xs == next_ys,
13391339
// If the current elements are not equal, the lists are not equal.

branches/auto/src/libserialize/json.rs

Lines changed: 23 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2205,6 +2205,10 @@ impl ToJson for ~str {
22052205
fn to_json(&self) -> Json { String((*self).clone()) }
22062206
}
22072207

2208+
impl ToJson for StrBuf {
2209+
fn to_json(&self) -> Json { String((*self).as_slice().into_owned()) }
2210+
}
2211+
22082212
impl<A:ToJson,B:ToJson> ToJson for (A, B) {
22092213
fn to_json(&self) -> Json {
22102214
match *self {
@@ -2643,41 +2647,25 @@ mod tests {
26432647

26442648
#[test]
26452649
fn test_decode_str() {
2646-
let mut decoder = Decoder::new(from_str("\"\"").unwrap());
2647-
let v: ~str = Decodable::decode(&mut decoder).unwrap();
2648-
assert_eq!(v, "".to_owned());
2649-
2650-
let mut decoder = Decoder::new(from_str("\"foo\"").unwrap());
2651-
let v: ~str = Decodable::decode(&mut decoder).unwrap();
2652-
assert_eq!(v, "foo".to_owned());
2653-
2654-
let mut decoder = Decoder::new(from_str("\"\\\"\"").unwrap());
2655-
let v: ~str = Decodable::decode(&mut decoder).unwrap();
2656-
assert_eq!(v, "\"".to_owned());
2657-
2658-
let mut decoder = Decoder::new(from_str("\"\\b\"").unwrap());
2659-
let v: ~str = Decodable::decode(&mut decoder).unwrap();
2660-
assert_eq!(v, "\x08".to_owned());
2661-
2662-
let mut decoder = Decoder::new(from_str("\"\\n\"").unwrap());
2663-
let v: ~str = Decodable::decode(&mut decoder).unwrap();
2664-
assert_eq!(v, "\n".to_owned());
2665-
2666-
let mut decoder = Decoder::new(from_str("\"\\r\"").unwrap());
2667-
let v: ~str = Decodable::decode(&mut decoder).unwrap();
2668-
assert_eq!(v, "\r".to_owned());
2669-
2670-
let mut decoder = Decoder::new(from_str("\"\\t\"").unwrap());
2671-
let v: ~str = Decodable::decode(&mut decoder).unwrap();
2672-
assert_eq!(v, "\t".to_owned());
2673-
2674-
let mut decoder = Decoder::new(from_str("\"\\u12ab\"").unwrap());
2675-
let v: ~str = Decodable::decode(&mut decoder).unwrap();
2676-
assert_eq!(v, "\u12ab".to_owned());
2677-
2678-
let mut decoder = Decoder::new(from_str("\"\\uAB12\"").unwrap());
2679-
let v: ~str = Decodable::decode(&mut decoder).unwrap();
2680-
assert_eq!(v, "\uAB12".to_owned());
2650+
let s = [("\"\"", ""),
2651+
("\"foo\"", "foo"),
2652+
("\"\\\"\"", "\""),
2653+
("\"\\b\"", "\x08"),
2654+
("\"\\n\"", "\n"),
2655+
("\"\\r\"", "\r"),
2656+
("\"\\t\"", "\t"),
2657+
("\"\\u12ab\"", "\u12ab"),
2658+
("\"\\uAB12\"", "\uAB12")];
2659+
2660+
for &(i, o) in s.iter() {
2661+
let mut decoder = Decoder::new(from_str(i).unwrap());
2662+
let v: StrBuf = Decodable::decode(&mut decoder).unwrap();
2663+
assert_eq!(v.as_slice(), o);
2664+
2665+
let mut decoder = Decoder::new(from_str(i).unwrap());
2666+
let v: ~str = Decodable::decode(&mut decoder).unwrap();
2667+
assert_eq!(v, o.to_owned());
2668+
}
26812669
}
26822670

26832671
#[test]

branches/auto/src/libserialize/serialize.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,18 @@ impl<E, D:Decoder<E>> Decodable<D, E> for ~str {
313313
}
314314
}
315315

316+
impl<E, S:Encoder<E>> Encodable<S, E> for StrBuf {
317+
fn encode(&self, s: &mut S) -> Result<(), E> {
318+
s.emit_str(self.as_slice())
319+
}
320+
}
321+
322+
impl<E, D:Decoder<E>> Decodable<D, E> for StrBuf {
323+
fn decode(d: &mut D) -> Result<StrBuf, E> {
324+
Ok(StrBuf::from_str(try!(d.read_str())))
325+
}
326+
}
327+
316328
impl<E, S:Encoder<E>> Encodable<S, E> for f32 {
317329
fn encode(&self, s: &mut S) -> Result<(), E> {
318330
s.emit_f32(*self)

0 commit comments

Comments
 (0)