Skip to content

Commit e367493

Browse files
committed
---
yaml --- r: 122634 b: refs/heads/snap-stage3 c: 954c323 h: refs/heads/master v: v3
1 parent ab75fb3 commit e367493

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
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 1bff1ff810dcfa8064c11e2b84473f053d1f69f1
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 6ae5e92cc226fc9252957df56afbd5fbd5b2b2a8
4+
refs/heads/snap-stage3: 954c3234a0c871856908ab0cabaf1b8ccbba9cbc
55
refs/heads/try: 2e9d9477b848cec778ca3f07ecdf0aea6ade23de
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/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)