Skip to content

Commit 575f58b

Browse files
committed
---
yaml --- r: 139419 b: refs/heads/try2 c: aa779c1 h: refs/heads/master i: 139417: 9d8a907 139415: b407075 v: v3
1 parent 12254d0 commit 575f58b

File tree

4 files changed

+18
-12
lines changed

4 files changed

+18
-12
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: ce9e5ecb6c1f833eccb520b4179cf86329331fa6
8+
refs/heads/try2: aa779c1240afd0f5e46897b6ddfa55126471bf19
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/libstd/ebml.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -411,13 +411,13 @@ pub mod reader {
411411
}
412412
413413
#[cfg(stage0)]
414-
fn read_option<T>(&self, f: &fn() -> T) -> Option<T> {
414+
fn read_option<T>(&self, f: &fn(bool) -> T) -> T {
415415
debug!("read_option()");
416416
do self.read_enum("Option") || {
417417
do self.read_enum_variant |idx| {
418418
match idx {
419-
0 => None,
420-
1 => Some(f()),
419+
0 => f(false),
420+
1 => f(true),
421421
_ => fail!(),
422422
}
423423
}
@@ -427,13 +427,13 @@ pub mod reader {
427427
#[cfg(stage1)]
428428
#[cfg(stage2)]
429429
#[cfg(stage3)]
430-
fn read_option<T>(&self, f: &fn() -> T) -> Option<T> {
430+
fn read_option<T>(&self, f: &fn(bool) -> T) -> T {
431431
debug!("read_option()");
432432
do self.read_enum("Option") || {
433433
do self.read_enum_variant(["None", "Some"]) |idx| {
434434
match idx {
435-
0 => None,
436-
1 => Some(f()),
435+
0 => f(false),
436+
1 => f(true),
437437
_ => fail!(),
438438
}
439439
}

branches/try2/src/libstd/json.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -980,10 +980,10 @@ impl<'self> serialize::Decoder for Decoder<'self> {
980980
}
981981
}
982982
983-
fn read_option<T>(&self, f: &fn() -> T) -> Option<T> {
983+
fn read_option<T>(&self, f: &fn(bool) -> T) -> T {
984984
match *self.peek() {
985-
Null => { self.pop(); None }
986-
_ => Some(f()),
985+
Null => { self.pop(); f(false) }
986+
_ => f(true),
987987
}
988988
}
989989
}

branches/try2/src/libstd/serialize.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ pub trait Decoder {
118118
fn read_tup_elt<T>(&self, idx: uint, f: &fn() -> T) -> T;
119119

120120
// Specialized types:
121-
fn read_option<T>(&self, f: &fn() -> T) -> Option<T>;
121+
fn read_option<T>(&self, f: &fn(bool) -> T) -> T;
122122
}
123123

124124
pub trait Encodable<S:Encoder> {
@@ -395,7 +395,13 @@ impl<S:Encoder,T:Encodable<S>> Encodable<S> for Option<T> {
395395

396396
impl<D:Decoder,T:Decodable<D>> Decodable<D> for Option<T> {
397397
fn decode(d: &D) -> Option<T> {
398-
d.read_option(|| Decodable::decode(d))
398+
do d.read_option |b| {
399+
if b {
400+
Some(Decodable::decode(d))
401+
} else {
402+
None
403+
}
404+
}
399405
}
400406
}
401407

0 commit comments

Comments
 (0)