Skip to content

Commit 76123fc

Browse files
committed
---
yaml --- r: 152974 b: refs/heads/try2 c: 954c323 h: refs/heads/master v: v3
1 parent 8ae263d commit 76123fc

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
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: 6ae5e92cc226fc9252957df56afbd5fbd5b2b2a8
8+
refs/heads/try2: 954c3234a0c871856908ab0cabaf1b8ccbba9cbc
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/libserialize/json.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2166,6 +2166,12 @@ impl fmt::Show for Json {
21662166
}
21672167
}
21682168

2169+
impl std::from_str::FromStr for Json {
2170+
fn from_str(s: &str) -> Option<Json> {
2171+
from_str(s).ok()
2172+
}
2173+
}
2174+
21692175
#[cfg(test)]
21702176
mod tests {
21712177
extern crate test;
@@ -2180,9 +2186,7 @@ mod tests {
21802186
InvalidSyntax, InvalidNumber, EOFWhileParsingObject, EOFWhileParsingList,
21812187
EOFWhileParsingValue, EOFWhileParsingString, KeyMustBeAString, ExpectedColon,
21822188
TrailingCharacters};
2183-
use std::f32;
2184-
use std::f64;
2185-
use std::io;
2189+
use std::{f32, f64, io};
21862190
use std::collections::TreeMap;
21872191

21882192
#[deriving(PartialEq, Encodable, Decodable, Show)]
@@ -2215,6 +2219,12 @@ mod tests {
22152219
Object(d)
22162220
}
22172221

2222+
#[test]
2223+
fn test_from_str_trait() {
2224+
let s = "null";
2225+
assert!(::std::from_str::from_str::<Json>(s).unwrap() == from_str(s).unwrap());
2226+
}
2227+
22182228
#[test]
22192229
fn test_write_null() {
22202230
assert_eq!(Null.to_str().into_string(), "null".to_string());

0 commit comments

Comments
 (0)