Skip to content

Move extra::json to libserialize #12453

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 25, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions mk/crates.mk
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@ DEPS_rustdoc := rustc native:sundown serialize sync getopts collections \
DEPS_flate := std native:miniz
DEPS_arena := std collections
DEPS_glob := std
DEPS_serialize := std
DEPS_serialize := std collections
DEPS_term := std collections
DEPS_semver := std
DEPS_uuid := std serialize
DEPS_sync := std
DEPS_getopts := std
DEPS_collections := std serialize
DEPS_collections := std
DEPS_fourcc := syntax std
DEPS_num := std extra
DEPS_num := std
DEPS_test := std extra collections getopts serialize term
DEPS_time := std serialize

Expand Down
12 changes: 6 additions & 6 deletions src/doc/rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -875,16 +875,16 @@ An example of what will and will not work for `use` items:

~~~~
# #[allow(unused_imports)];
use foo::extra::json; // good: foo is at the root of the crate
use foo::native::start; // good: foo is at the root of the crate
use foo::baz::foobaz; // good: foo is at the root of the crate

mod foo {
extern crate extra;
extern crate native;

use foo::extra::json; // good: foo is at crate root
// use extra::json::*; // bad: extra is not at the crate root
use self::baz::foobaz; // good: self refers to module 'foo'
use foo::bar::foobar; // good: foo is at crate root
use foo::native::start; // good: foo is at crate root
// use native::start; // bad: native is not at the crate root
use self::baz::foobaz; // good: self refers to module 'foo'
use foo::bar::foobar; // good: foo is at crate root

pub mod bar {
pub fn foobar() { }
Expand Down
27 changes: 0 additions & 27 deletions src/libcollections/dlist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ use std::iter;

use deque::Deque;

use serialize::{Encodable, Decodable, Encoder, Decoder};

/// A doubly-linked list.
pub struct DList<T> {
priv length: uint,
Expand Down Expand Up @@ -630,31 +628,6 @@ impl<A: Clone> Clone for DList<A> {
}
}

impl<
S: Encoder,
T: Encodable<S>
> Encodable<S> for DList<T> {
fn encode(&self, s: &mut S) {
s.emit_seq(self.len(), |s| {
for (i, e) in self.iter().enumerate() {
s.emit_seq_elt(i, |s| e.encode(s));
}
})
}
}

impl<D:Decoder,T:Decodable<D>> Decodable<D> for DList<T> {
fn decode(d: &mut D) -> DList<T> {
let mut list = DList::new();
d.read_seq(|d, len| {
for i in range(0u, len) {
list.push_back(d.read_seq_elt(i, |d| Decodable::decode(d)));
}
});
list
}
}

#[cfg(test)]
mod tests {
extern crate test;
Expand Down
2 changes: 1 addition & 1 deletion src/libcollections/enum_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

use std::num::Bitwise;

#[deriving(Clone, Eq, Hash, Show, Encodable, Decodable)]
#[deriving(Clone, Eq, Hash, Show)]
/// A specialized Set implementation to use enum types.
pub struct EnumSet<E> {
// We must maintain the invariant that no bits are set
Expand Down
67 changes: 0 additions & 67 deletions src/libcollections/hashmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ use std::vec::{Items, MutItems};
use std::vec_ng::Vec;
use std::vec_ng;

use serialize::{Encodable, Decodable, Encoder, Decoder};

static INITIAL_CAPACITY: uint = 32u; // 2^5

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

impl<
E: Encoder,
K: Encodable<E> + Hash + Eq,
V: Encodable<E>
> Encodable<E> for HashMap<K, V> {
fn encode(&self, e: &mut E) {
e.emit_map(self.len(), |e| {
let mut i = 0;
for (key, val) in self.iter() {
e.emit_map_elt_key(i, |e| key.encode(e));
e.emit_map_elt_val(i, |e| val.encode(e));
i += 1;
}
})
}
}

impl<
D: Decoder,
K: Decodable<D> + Hash + Eq,
V: Decodable<D>
> Decodable<D> for HashMap<K, V> {
fn decode(d: &mut D) -> HashMap<K, V> {
d.read_map(|d, len| {
let mut map = HashMap::with_capacity(len);
for i in range(0u, len) {
let key = d.read_map_elt_key(i, |d| Decodable::decode(d));
let val = d.read_map_elt_val(i, |d| Decodable::decode(d));
map.insert(key, val);
}
map
})
}
}

impl<
S: Encoder,
T: Encodable<S> + Hash + Eq
> Encodable<S> for HashSet<T> {
fn encode(&self, s: &mut S) {
s.emit_seq(self.len(), |s| {
let mut i = 0;
for e in self.iter() {
s.emit_seq_elt(i, |s| e.encode(s));
i += 1;
}
})
}
}

impl<
D: Decoder,
T: Decodable<D> + Hash + Eq
> Decodable<D> for HashSet<T> {
fn decode(d: &mut D) -> HashSet<T> {
d.read_seq(|d, len| {
let mut set = HashSet::with_capacity(len);
for i in range(0u, len) {
set.insert(d.read_seq_elt(i, |d| Decodable::decode(d)));
}
set
})
}
}

#[cfg(test)]
mod test_map {
use super::{HashMap, HashSet};
Expand Down
1 change: 0 additions & 1 deletion src/libcollections/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

#[feature(macro_rules, managed_boxes)];

extern crate serialize;
#[cfg(test)] extern crate test;

pub use bitv::Bitv;
Expand Down
27 changes: 0 additions & 27 deletions src/libcollections/ringbuf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ use std::iter::{Rev, RandomAccessIterator};

use deque::Deque;

use serialize::{Encodable, Decodable, Encoder, Decoder};

static INITIAL_CAPACITY: uint = 8u; // 2^3
static MINIMUM_CAPACITY: uint = 2u;

Expand Down Expand Up @@ -404,31 +402,6 @@ impl<A> Extendable<A> for RingBuf<A> {
}
}

impl<
S: Encoder,
T: Encodable<S>
> Encodable<S> for RingBuf<T> {
fn encode(&self, s: &mut S) {
s.emit_seq(self.len(), |s| {
for (i, e) in self.iter().enumerate() {
s.emit_seq_elt(i, |s| e.encode(s));
}
})
}
}

impl<D:Decoder,T:Decodable<D>> Decodable<D> for RingBuf<T> {
fn decode(d: &mut D) -> RingBuf<T> {
let mut deque = RingBuf::new();
d.read_seq(|d, len| {
for i in range(0u, len) {
deque.push_back(d.read_seq_elt(i, |d| Decodable::decode(d)));
}
});
deque
}
}

#[cfg(test)]
mod tests {
extern crate test;
Expand Down
67 changes: 0 additions & 67 deletions src/libcollections/treemap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ use std::cmp::Ordering;
use std::mem::{replace, swap};
use std::ptr;

use serialize::{Encodable, Decodable, Encoder, Decoder};

// This is implemented as an AA tree, which is a simplified variation of
// a red-black tree where red (horizontal) nodes can only be added
// as a right child. The time complexity is the same, and re-balancing
Expand Down Expand Up @@ -1006,71 +1004,6 @@ impl<T: TotalOrd> Extendable<T> for TreeSet<T> {
}
}

impl<
E: Encoder,
K: Encodable<E> + Eq + TotalOrd,
V: Encodable<E> + Eq
> Encodable<E> for TreeMap<K, V> {
fn encode(&self, e: &mut E) {
e.emit_map(self.len(), |e| {
let mut i = 0;
for (key, val) in self.iter() {
e.emit_map_elt_key(i, |e| key.encode(e));
e.emit_map_elt_val(i, |e| val.encode(e));
i += 1;
}
})
}
}

impl<
D: Decoder,
K: Decodable<D> + Eq + TotalOrd,
V: Decodable<D> + Eq
> Decodable<D> for TreeMap<K, V> {
fn decode(d: &mut D) -> TreeMap<K, V> {
d.read_map(|d, len| {
let mut map = TreeMap::new();
for i in range(0u, len) {
let key = d.read_map_elt_key(i, |d| Decodable::decode(d));
let val = d.read_map_elt_val(i, |d| Decodable::decode(d));
map.insert(key, val);
}
map
})
}
}

impl<
S: Encoder,
T: Encodable<S> + Eq + TotalOrd
> Encodable<S> for TreeSet<T> {
fn encode(&self, s: &mut S) {
s.emit_seq(self.len(), |s| {
let mut i = 0;
for e in self.iter() {
s.emit_seq_elt(i, |s| e.encode(s));
i += 1;
}
})
}
}

impl<
D: Decoder,
T: Decodable<D> + Eq + TotalOrd
> Decodable<D> for TreeSet<T> {
fn decode(d: &mut D) -> TreeSet<T> {
d.read_seq(|d, len| {
let mut set = TreeSet::new();
for i in range(0u, len) {
set.insert(d.read_seq_elt(i, |d| Decodable::decode(d)));
}
set
})
}
}

#[cfg(test)]
mod test_treemap {

Expand Down
55 changes: 0 additions & 55 deletions src/libcollections/trie.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ use std::mem::init;
use std::vec;
use std::vec::{Items, MutItems};

use serialize::{Encodable, Decodable, Encoder, Decoder};

// FIXME: #5244: need to manually update the TrieNode constructor
static SHIFT: uint = 4;
static SIZE: uint = 1 << SHIFT;
Expand Down Expand Up @@ -620,59 +618,6 @@ impl<'a> Iterator<uint> for SetItems<'a> {
}
}

impl<
E: Encoder,
V: Encodable<E>
> Encodable<E> for TrieMap<V> {
fn encode(&self, e: &mut E) {
e.emit_map(self.len(), |e| {
for (i, (key, val)) in self.iter().enumerate() {
e.emit_map_elt_key(i, |e| key.encode(e));
e.emit_map_elt_val(i, |e| val.encode(e));
}
});
}
}

impl<
D: Decoder,
V: Decodable<D>
> Decodable<D> for TrieMap<V> {
fn decode(d: &mut D) -> TrieMap<V> {
d.read_map(|d, len| {
let mut map = TrieMap::new();
for i in range(0u, len) {
let key = d.read_map_elt_key(i, |d| Decodable::decode(d));
let val = d.read_map_elt_val(i, |d| Decodable::decode(d));
map.insert(key, val);
}
map
})
}
}

impl<S: Encoder> Encodable<S> for TrieSet {
fn encode(&self, s: &mut S) {
s.emit_seq(self.len(), |s| {
for (i, e) in self.iter().enumerate() {
s.emit_seq_elt(i, |s| e.encode(s));
}
})
}
}

impl<D: Decoder> Decodable<D> for TrieSet {
fn decode(d: &mut D) -> TrieSet {
d.read_seq(|d, len| {
let mut set = TrieSet::new();
for i in range(0u, len) {
set.insert(d.read_seq_elt(i, |d| Decodable::decode(d)));
}
set
})
}
}

#[cfg(test)]
mod test_map {
use super::{TrieMap, TrieNode, Internal, External};
Expand Down
10 changes: 0 additions & 10 deletions src/libextra/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,9 @@ extern crate time;
// Utility modules
pub mod c_vec;
pub mod url;
pub mod json;
pub mod tempfile;
pub mod workcache;
pub mod stats;

#[cfg(unicode)]
mod unicode;

// A curious inner-module that's not exported that contains the binding
// 'extra' so that macro-expanded references to extra::serialize and such
// can be resolved within libextra.
#[doc(hidden)]
pub mod extra {
pub use serialize;
}

Loading