Skip to content

Commit 6485917

Browse files
committed
Move extra::json to libserialize
This also inverts the dependency between libserialize and libcollections. cc #8784
1 parent 6720977 commit 6485917

File tree

26 files changed

+340
-331
lines changed

26 files changed

+340
-331
lines changed

mk/crates.mk

+3-3
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,15 @@ DEPS_rustdoc := rustc native:sundown serialize sync getopts collections \
6868
DEPS_flate := std native:miniz
6969
DEPS_arena := std collections
7070
DEPS_glob := std
71-
DEPS_serialize := std
71+
DEPS_serialize := std collections
7272
DEPS_term := std collections
7373
DEPS_semver := std
7474
DEPS_uuid := std serialize
7575
DEPS_sync := std
7676
DEPS_getopts := std
77-
DEPS_collections := std serialize
77+
DEPS_collections := std
7878
DEPS_fourcc := syntax std
79-
DEPS_num := std extra
79+
DEPS_num := std
8080
DEPS_test := std extra collections getopts serialize term
8181
DEPS_time := std serialize
8282

src/doc/rust.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -875,16 +875,16 @@ An example of what will and will not work for `use` items:
875875

876876
~~~~
877877
# #[allow(unused_imports)];
878-
use foo::extra::json; // good: foo is at the root of the crate
878+
use foo::native::start; // good: foo is at the root of the crate
879879
use foo::baz::foobaz; // good: foo is at the root of the crate
880880
881881
mod foo {
882-
extern crate extra;
882+
extern crate native;
883883
884-
use foo::extra::json; // good: foo is at crate root
885-
// use extra::json::*; // bad: extra is not at the crate root
886-
use self::baz::foobaz; // good: self refers to module 'foo'
887-
use foo::bar::foobar; // good: foo is at crate root
884+
use foo::native::start; // good: foo is at crate root
885+
// use native::start; // bad: native is not at the crate root
886+
use self::baz::foobaz; // good: self refers to module 'foo'
887+
use foo::bar::foobar; // good: foo is at crate root
888888
889889
pub mod bar {
890890
pub fn foobar() { }

src/libcollections/dlist.rs

-27
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ use std::iter;
3030

3131
use deque::Deque;
3232

33-
use serialize::{Encodable, Decodable, Encoder, Decoder};
34-
3533
/// A doubly-linked list.
3634
pub struct DList<T> {
3735
priv length: uint,
@@ -630,31 +628,6 @@ impl<A: Clone> Clone for DList<A> {
630628
}
631629
}
632630

633-
impl<
634-
S: Encoder,
635-
T: Encodable<S>
636-
> Encodable<S> for DList<T> {
637-
fn encode(&self, s: &mut S) {
638-
s.emit_seq(self.len(), |s| {
639-
for (i, e) in self.iter().enumerate() {
640-
s.emit_seq_elt(i, |s| e.encode(s));
641-
}
642-
})
643-
}
644-
}
645-
646-
impl<D:Decoder,T:Decodable<D>> Decodable<D> for DList<T> {
647-
fn decode(d: &mut D) -> DList<T> {
648-
let mut list = DList::new();
649-
d.read_seq(|d, len| {
650-
for i in range(0u, len) {
651-
list.push_back(d.read_seq_elt(i, |d| Decodable::decode(d)));
652-
}
653-
});
654-
list
655-
}
656-
}
657-
658631
#[cfg(test)]
659632
mod tests {
660633
extern crate test;

src/libcollections/enum_set.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
1616
use std::num::Bitwise;
1717

18-
#[deriving(Clone, Eq, Hash, Show, Encodable, Decodable)]
18+
#[deriving(Clone, Eq, Hash, Show)]
1919
/// A specialized Set implementation to use enum types.
2020
pub struct EnumSet<E> {
2121
// We must maintain the invariant that no bits are set

src/libcollections/hashmap.rs

-67
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@ use std::vec::{Items, MutItems};
6565
use std::vec_ng::Vec;
6666
use std::vec_ng;
6767

68-
use serialize::{Encodable, Decodable, Encoder, Decoder};
69-
7068
static INITIAL_CAPACITY: uint = 32u; // 2^5
7169

7270
struct Bucket<K,V> {
@@ -912,71 +910,6 @@ pub type SetAlgebraItems<'a, T> =
912910
FilterMap<'static,(&'a HashSet<T>, &'a T), &'a T,
913911
Zip<Repeat<&'a HashSet<T>>,SetItems<'a,T>>>;
914912

915-
impl<
916-
E: Encoder,
917-
K: Encodable<E> + Hash + Eq,
918-
V: Encodable<E>
919-
> Encodable<E> for HashMap<K, V> {
920-
fn encode(&self, e: &mut E) {
921-
e.emit_map(self.len(), |e| {
922-
let mut i = 0;
923-
for (key, val) in self.iter() {
924-
e.emit_map_elt_key(i, |e| key.encode(e));
925-
e.emit_map_elt_val(i, |e| val.encode(e));
926-
i += 1;
927-
}
928-
})
929-
}
930-
}
931-
932-
impl<
933-
D: Decoder,
934-
K: Decodable<D> + Hash + Eq,
935-
V: Decodable<D>
936-
> Decodable<D> for HashMap<K, V> {
937-
fn decode(d: &mut D) -> HashMap<K, V> {
938-
d.read_map(|d, len| {
939-
let mut map = HashMap::with_capacity(len);
940-
for i in range(0u, len) {
941-
let key = d.read_map_elt_key(i, |d| Decodable::decode(d));
942-
let val = d.read_map_elt_val(i, |d| Decodable::decode(d));
943-
map.insert(key, val);
944-
}
945-
map
946-
})
947-
}
948-
}
949-
950-
impl<
951-
S: Encoder,
952-
T: Encodable<S> + Hash + Eq
953-
> Encodable<S> for HashSet<T> {
954-
fn encode(&self, s: &mut S) {
955-
s.emit_seq(self.len(), |s| {
956-
let mut i = 0;
957-
for e in self.iter() {
958-
s.emit_seq_elt(i, |s| e.encode(s));
959-
i += 1;
960-
}
961-
})
962-
}
963-
}
964-
965-
impl<
966-
D: Decoder,
967-
T: Decodable<D> + Hash + Eq
968-
> Decodable<D> for HashSet<T> {
969-
fn decode(d: &mut D) -> HashSet<T> {
970-
d.read_seq(|d, len| {
971-
let mut set = HashSet::with_capacity(len);
972-
for i in range(0u, len) {
973-
set.insert(d.read_seq_elt(i, |d| Decodable::decode(d)));
974-
}
975-
set
976-
})
977-
}
978-
}
979-
980913
#[cfg(test)]
981914
mod test_map {
982915
use super::{HashMap, HashSet};

src/libcollections/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
#[feature(macro_rules, managed_boxes)];
2121

22-
extern crate serialize;
2322
#[cfg(test)] extern crate test;
2423

2524
pub use bitv::Bitv;

src/libcollections/ringbuf.rs

-27
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ use std::iter::{Rev, RandomAccessIterator};
1919

2020
use deque::Deque;
2121

22-
use serialize::{Encodable, Decodable, Encoder, Decoder};
23-
2422
static INITIAL_CAPACITY: uint = 8u; // 2^3
2523
static MINIMUM_CAPACITY: uint = 2u;
2624

@@ -404,31 +402,6 @@ impl<A> Extendable<A> for RingBuf<A> {
404402
}
405403
}
406404

407-
impl<
408-
S: Encoder,
409-
T: Encodable<S>
410-
> Encodable<S> for RingBuf<T> {
411-
fn encode(&self, s: &mut S) {
412-
s.emit_seq(self.len(), |s| {
413-
for (i, e) in self.iter().enumerate() {
414-
s.emit_seq_elt(i, |s| e.encode(s));
415-
}
416-
})
417-
}
418-
}
419-
420-
impl<D:Decoder,T:Decodable<D>> Decodable<D> for RingBuf<T> {
421-
fn decode(d: &mut D) -> RingBuf<T> {
422-
let mut deque = RingBuf::new();
423-
d.read_seq(|d, len| {
424-
for i in range(0u, len) {
425-
deque.push_back(d.read_seq_elt(i, |d| Decodable::decode(d)));
426-
}
427-
});
428-
deque
429-
}
430-
}
431-
432405
#[cfg(test)]
433406
mod tests {
434407
extern crate test;

src/libcollections/treemap.rs

-67
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ use std::cmp::Ordering;
1717
use std::mem::{replace, swap};
1818
use std::ptr;
1919

20-
use serialize::{Encodable, Decodable, Encoder, Decoder};
21-
2220
// This is implemented as an AA tree, which is a simplified variation of
2321
// a red-black tree where red (horizontal) nodes can only be added
2422
// as a right child. The time complexity is the same, and re-balancing
@@ -1006,71 +1004,6 @@ impl<T: TotalOrd> Extendable<T> for TreeSet<T> {
10061004
}
10071005
}
10081006

1009-
impl<
1010-
E: Encoder,
1011-
K: Encodable<E> + Eq + TotalOrd,
1012-
V: Encodable<E> + Eq
1013-
> Encodable<E> for TreeMap<K, V> {
1014-
fn encode(&self, e: &mut E) {
1015-
e.emit_map(self.len(), |e| {
1016-
let mut i = 0;
1017-
for (key, val) in self.iter() {
1018-
e.emit_map_elt_key(i, |e| key.encode(e));
1019-
e.emit_map_elt_val(i, |e| val.encode(e));
1020-
i += 1;
1021-
}
1022-
})
1023-
}
1024-
}
1025-
1026-
impl<
1027-
D: Decoder,
1028-
K: Decodable<D> + Eq + TotalOrd,
1029-
V: Decodable<D> + Eq
1030-
> Decodable<D> for TreeMap<K, V> {
1031-
fn decode(d: &mut D) -> TreeMap<K, V> {
1032-
d.read_map(|d, len| {
1033-
let mut map = TreeMap::new();
1034-
for i in range(0u, len) {
1035-
let key = d.read_map_elt_key(i, |d| Decodable::decode(d));
1036-
let val = d.read_map_elt_val(i, |d| Decodable::decode(d));
1037-
map.insert(key, val);
1038-
}
1039-
map
1040-
})
1041-
}
1042-
}
1043-
1044-
impl<
1045-
S: Encoder,
1046-
T: Encodable<S> + Eq + TotalOrd
1047-
> Encodable<S> for TreeSet<T> {
1048-
fn encode(&self, s: &mut S) {
1049-
s.emit_seq(self.len(), |s| {
1050-
let mut i = 0;
1051-
for e in self.iter() {
1052-
s.emit_seq_elt(i, |s| e.encode(s));
1053-
i += 1;
1054-
}
1055-
})
1056-
}
1057-
}
1058-
1059-
impl<
1060-
D: Decoder,
1061-
T: Decodable<D> + Eq + TotalOrd
1062-
> Decodable<D> for TreeSet<T> {
1063-
fn decode(d: &mut D) -> TreeSet<T> {
1064-
d.read_seq(|d, len| {
1065-
let mut set = TreeSet::new();
1066-
for i in range(0u, len) {
1067-
set.insert(d.read_seq_elt(i, |d| Decodable::decode(d)));
1068-
}
1069-
set
1070-
})
1071-
}
1072-
}
1073-
10741007
#[cfg(test)]
10751008
mod test_treemap {
10761009

src/libcollections/trie.rs

-55
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ use std::mem::init;
1616
use std::vec;
1717
use std::vec::{Items, MutItems};
1818

19-
use serialize::{Encodable, Decodable, Encoder, Decoder};
20-
2119
// FIXME: #5244: need to manually update the TrieNode constructor
2220
static SHIFT: uint = 4;
2321
static SIZE: uint = 1 << SHIFT;
@@ -620,59 +618,6 @@ impl<'a> Iterator<uint> for SetItems<'a> {
620618
}
621619
}
622620

623-
impl<
624-
E: Encoder,
625-
V: Encodable<E>
626-
> Encodable<E> for TrieMap<V> {
627-
fn encode(&self, e: &mut E) {
628-
e.emit_map(self.len(), |e| {
629-
for (i, (key, val)) in self.iter().enumerate() {
630-
e.emit_map_elt_key(i, |e| key.encode(e));
631-
e.emit_map_elt_val(i, |e| val.encode(e));
632-
}
633-
});
634-
}
635-
}
636-
637-
impl<
638-
D: Decoder,
639-
V: Decodable<D>
640-
> Decodable<D> for TrieMap<V> {
641-
fn decode(d: &mut D) -> TrieMap<V> {
642-
d.read_map(|d, len| {
643-
let mut map = TrieMap::new();
644-
for i in range(0u, len) {
645-
let key = d.read_map_elt_key(i, |d| Decodable::decode(d));
646-
let val = d.read_map_elt_val(i, |d| Decodable::decode(d));
647-
map.insert(key, val);
648-
}
649-
map
650-
})
651-
}
652-
}
653-
654-
impl<S: Encoder> Encodable<S> for TrieSet {
655-
fn encode(&self, s: &mut S) {
656-
s.emit_seq(self.len(), |s| {
657-
for (i, e) in self.iter().enumerate() {
658-
s.emit_seq_elt(i, |s| e.encode(s));
659-
}
660-
})
661-
}
662-
}
663-
664-
impl<D: Decoder> Decodable<D> for TrieSet {
665-
fn decode(d: &mut D) -> TrieSet {
666-
d.read_seq(|d, len| {
667-
let mut set = TrieSet::new();
668-
for i in range(0u, len) {
669-
set.insert(d.read_seq_elt(i, |d| Decodable::decode(d)));
670-
}
671-
set
672-
})
673-
}
674-
}
675-
676621
#[cfg(test)]
677622
mod test_map {
678623
use super::{TrieMap, TrieNode, Internal, External};

src/libextra/lib.rs

-10
Original file line numberDiff line numberDiff line change
@@ -42,19 +42,9 @@ extern crate time;
4242
// Utility modules
4343
pub mod c_vec;
4444
pub mod url;
45-
pub mod json;
4645
pub mod tempfile;
4746
pub mod workcache;
4847
pub mod stats;
4948

5049
#[cfg(unicode)]
5150
mod unicode;
52-
53-
// A curious inner-module that's not exported that contains the binding
54-
// 'extra' so that macro-expanded references to extra::serialize and such
55-
// can be resolved within libextra.
56-
#[doc(hidden)]
57-
pub mod extra {
58-
pub use serialize;
59-
}
60-

0 commit comments

Comments
 (0)