Skip to content

Commit 9880da4

Browse files
author
Jorge Aparicio
committed
---
yaml --- r: 152229 b: refs/heads/try2 c: a413d00 h: refs/heads/master i: 152227: 48ae73a v: v3
1 parent 38feaaa commit 9880da4

File tree

4 files changed

+59
-16
lines changed

4 files changed

+59
-16
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: 7fa5baa7cae5ba84cdd50cfebc729ea82c0a2f39
8+
refs/heads/try2: a413d005a77d294f6e7b173b898684d56224b19f
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/README.md

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,37 +5,26 @@ Source layout:
55
| Path | Description |
66
| ------------------- | --------------------------------------------------------- |
77
| `librustc/` | The self-hosted compiler |
8-
| `liballoc/` | Rust's core allocation library |
9-
| `libcore/` | The Rust core library |
10-
| `libdebug/` | Debugging utilities |
118
| `libstd/` | The standard library (imported and linked by default) |
9+
| `libextra/` | The "extras" library (slightly more peripheral code) |
1210
| `libgreen/` | The M:N runtime library |
1311
| `libnative/` | The 1:1 runtime library |
1412
| `libsyntax/` | The Rust parser and pretty-printer |
13+
| `libcollections/` | A collection of useful data structures and containers |
14+
| `libnum/` | Extended number support library (complex, rational, etc) |
1515
| `libtest/` | Rust's test-runner code |
1616
| ------------------- | --------------------------------------------------------- |
1717
| `libarena/` | The arena (a fast but limited) memory allocator |
18-
| `libbacktrace/` | The libbacktrace library |
19-
| `libcollections/` | A collection of useful data structures and containers |
2018
| `libflate/` | Simple compression library |
21-
| `libfmt_macros/` | Macro support for format strings |
2219
| `libfourcc/` | Data format identifier library |
2320
| `libgetopts/` | Get command-line-options library |
2421
| `libglob/` | Unix glob patterns library |
25-
| `libgraphviz/` | Generating files for Graphviz |
26-
| `libhexfloat/` | Hexadecimal floating-point literals |
27-
| `liblibc/` | Bindings for the C standard library |
28-
| `liblog/` | Utilities for program-wide and customizable logging |
29-
| `libnum/` | Extended number support library (complex, rational, etc) |
30-
| `librand/` | Random numbers and distributions |
3122
| `libregex/` | Regular expressions |
32-
| `libregex_macros/` | The regex! syntax extension |
3323
| `libsemver/` | Rust's semantic versioning library |
3424
| `libserialize/` | Encode-Decode types library |
3525
| `libsync/` | Concurrency mechanisms and primitives |
3626
| `libterm/` | ANSI color library for terminals |
3727
| `libtime/` | Time operations library |
38-
| `liburl/` | URL handling lirary |
3928
| `libuuid/` | UUID's handling code |
4029
| ------------------- | --------------------------------------------------------- |
4130
| `rt/` | The runtime system |

branches/try2/src/doc/intro.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ and its implications on a task that programmers usually find very difficult: con
1818

1919
Ownership is central to Rust,
2020
and is the feature from which many of Rust's powerful capabilities are derived.
21-
"Ownership" refers to which parts of your code are allowed to read,
21+
"Ownership" refers to which parts of your code are allowed read,
2222
write, and ultimately release, memory.
2323
Let's start by looking at some C++ code:
2424

branches/try2/src/libserialize/json.rs

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2227,6 +2227,10 @@ impl<A:ToJson,B:ToJson,C:ToJson> ToJson for (A, B, C) {
22272227
}
22282228
}
22292229

2230+
impl<'a, A:ToJson> ToJson for &'a [A] {
2231+
fn to_json(&self) -> Json { List(self.iter().map(|elt| elt.to_json()).collect()) }
2232+
}
2233+
22302234
impl<A:ToJson> ToJson for ~[A] {
22312235
fn to_json(&self) -> Json { List(self.iter().map(|elt| elt.to_json()).collect()) }
22322236
}
@@ -3334,6 +3338,56 @@ mod tests {
33343338
assert!(stack.get(1) == Key("foo"));
33353339
}
33363340

3341+
#[test]
3342+
fn test_to_json() {
3343+
use collections::{HashMap,TreeMap};
3344+
use super::ToJson;
3345+
3346+
let list2 = List(vec!(Number(1.0_f64), Number(2.0_f64)));
3347+
let list3 = List(vec!(Number(1.0f64), Number(2.0f64), Number(3.0f64)));
3348+
let object = {
3349+
let mut tree_map = TreeMap::new();
3350+
tree_map.insert("a".to_string(), Number(1.0_f64));
3351+
tree_map.insert("b".to_string(), Number(2.0_f64));
3352+
Object(box tree_map)
3353+
};
3354+
3355+
assert_eq!(list2.to_json(), list2);
3356+
assert_eq!(object.to_json(), object);
3357+
assert_eq!(3_i.to_json(), Number(3.0_f64));
3358+
assert_eq!(4_i8.to_json(), Number(4.0_f64));
3359+
assert_eq!(5_i16.to_json(), Number(5.0_f64));
3360+
assert_eq!(6_i32.to_json(), Number(6.0_f64));
3361+
assert_eq!(7_i64.to_json(), Number(7.0_f64));
3362+
assert_eq!(8_u.to_json(), Number(8.0_f64));
3363+
assert_eq!(9_u8.to_json(), Number(9.0_f64));
3364+
assert_eq!(10_u16.to_json(), Number(10.0_f64));
3365+
assert_eq!(11_u32.to_json(), Number(11.0_f64));
3366+
assert_eq!(12_u64.to_json(), Number(12.0_f64));
3367+
assert_eq!(13.0_f32.to_json(), Number(13.0_f64));
3368+
assert_eq!(14.0_f64.to_json(), Number(14.0_f64));
3369+
assert_eq!(().to_json(), Null);
3370+
assert_eq!(true.to_json(), Boolean(true));
3371+
assert_eq!(false.to_json(), Boolean(false));
3372+
assert_eq!("abc".to_string().to_json(), String("abc".to_string()));
3373+
assert_eq!((1, 2).to_json(), list2);
3374+
assert_eq!((1, 2, 3).to_json(), list3);
3375+
assert_eq!([1, 2].to_json(), list2);
3376+
assert_eq!((&[1, 2, 3]).to_json(), list3);
3377+
assert_eq!((~[1, 2]).to_json(), list2);
3378+
assert_eq!(vec!(1, 2, 3).to_json(), list3);
3379+
let mut tree_map = TreeMap::new();
3380+
tree_map.insert("a".to_string(), 1);
3381+
tree_map.insert("b".to_string(), 2);
3382+
assert_eq!(tree_map.to_json(), object);
3383+
let mut hash_map = HashMap::new();
3384+
hash_map.insert("a".to_string(), 1);
3385+
hash_map.insert("b".to_string(), 2);
3386+
assert_eq!(hash_map.to_json(), object);
3387+
assert_eq!(Some(15).to_json(), Number(15 as f64));
3388+
assert_eq!(None::<int>.to_json(), Null);
3389+
}
3390+
33373391
#[bench]
33383392
fn bench_streaming_small(b: &mut Bencher) {
33393393
b.iter( || {

0 commit comments

Comments
 (0)