commit
8f51ad2420
@ -8,7 +8,7 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use std::prelude::*;
|
||||
use prelude::*;
|
||||
use std::rand;
|
||||
use std::rand::Rng;
|
||||
use test::Bencher;
|
||||
|
@ -617,10 +617,9 @@ impl<T: Ord> Extend<T> for BinaryHeap<T> {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::prelude::*;
|
||||
use prelude::*;
|
||||
|
||||
use super::BinaryHeap;
|
||||
use vec::Vec;
|
||||
|
||||
#[test]
|
||||
fn test_iterator() {
|
||||
|
@ -1686,16 +1686,15 @@ impl<'a> Iterator<uint> for TwoBitPositions<'a> {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::prelude::*;
|
||||
use std::iter::range_step;
|
||||
use prelude::*;
|
||||
use core::iter::range_step;
|
||||
use core::u32;
|
||||
use std::rand;
|
||||
use std::rand::Rng;
|
||||
use std::u32;
|
||||
use test::{Bencher, black_box};
|
||||
|
||||
use super::{Bitv, BitvSet, from_fn, from_bytes};
|
||||
use bitv;
|
||||
use vec::Vec;
|
||||
|
||||
static BENCH_BITS : uint = 1 << 14;
|
||||
|
||||
@ -2038,7 +2037,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_from_bytes() {
|
||||
let bitv = from_bytes(&[0b10110110, 0b00000000, 0b11111111]);
|
||||
let str = format!("{}{}{}", "10110110", "00000000", "11111111");
|
||||
let str = concat!("10110110", "00000000", "11111111");
|
||||
assert_eq!(bitv.to_string(), str);
|
||||
}
|
||||
|
||||
|
@ -131,12 +131,12 @@ pub enum Entry<'a, K:'a, V:'a> {
|
||||
/// A vacant Entry.
|
||||
pub struct VacantEntry<'a, K:'a, V:'a> {
|
||||
key: K,
|
||||
stack: stack::SearchStack<'a, K, V, node::Edge, node::Leaf>,
|
||||
stack: stack::SearchStack<'a, K, V, node::handle::Edge, node::handle::Leaf>,
|
||||
}
|
||||
|
||||
/// An occupied Entry.
|
||||
pub struct OccupiedEntry<'a, K:'a, V:'a> {
|
||||
stack: stack::SearchStack<'a, K, V, node::KV, node::LeafOrInternal>,
|
||||
stack: stack::SearchStack<'a, K, V, node::handle::KV, node::handle::LeafOrInternal>,
|
||||
}
|
||||
|
||||
impl<K: Ord, V> BTreeMap<K, V> {
|
||||
@ -496,7 +496,8 @@ mod stack {
|
||||
use core::kinds::marker;
|
||||
use core::mem;
|
||||
use super::BTreeMap;
|
||||
use super::super::node::{mod, Node, Fit, Split, KV, Edge, Internal, Leaf, LeafOrInternal};
|
||||
use super::super::node::{mod, Node, Fit, Split, Internal, Leaf};
|
||||
use super::super::node::handle;
|
||||
use vec::Vec;
|
||||
|
||||
/// A generic mutable reference, identical to `&mut` except for the fact that its lifetime
|
||||
@ -520,7 +521,7 @@ mod stack {
|
||||
}
|
||||
}
|
||||
|
||||
type StackItem<K, V> = node::Handle<*mut Node<K, V>, Edge, Internal>;
|
||||
type StackItem<K, V> = node::Handle<*mut Node<K, V>, handle::Edge, handle::Internal>;
|
||||
type Stack<K, V> = Vec<StackItem<K, V>>;
|
||||
|
||||
/// A `PartialSearchStack` handles the construction of a search stack.
|
||||
@ -595,7 +596,9 @@ mod stack {
|
||||
/// Pushes the requested child of the stack's current top on top of the stack. If the child
|
||||
/// exists, then a new PartialSearchStack is yielded. Otherwise, a VacantSearchStack is
|
||||
/// yielded.
|
||||
pub fn push(mut self, mut edge: node::Handle<IdRef<'id, Node<K, V>>, Edge, Internal>)
|
||||
pub fn push(mut self, mut edge: node::Handle<IdRef<'id, Node<K, V>>,
|
||||
handle::Edge,
|
||||
handle::Internal>)
|
||||
-> PartialSearchStack<'a, K, V> {
|
||||
self.stack.push(edge.as_raw());
|
||||
PartialSearchStack {
|
||||
@ -617,7 +620,7 @@ mod stack {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, K, V, NodeType> SearchStack<'a, K, V, KV, NodeType> {
|
||||
impl<'a, K, V, NodeType> SearchStack<'a, K, V, handle::KV, NodeType> {
|
||||
/// Gets a reference to the value the stack points to.
|
||||
pub fn peek(&self) -> &V {
|
||||
unsafe { self.top.from_raw().into_kv().1 }
|
||||
@ -640,7 +643,7 @@ mod stack {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, K, V> SearchStack<'a, K, V, KV, Leaf> {
|
||||
impl<'a, K, V> SearchStack<'a, K, V, handle::KV, handle::Leaf> {
|
||||
/// Removes the key and value in the top element of the stack, then handles underflows as
|
||||
/// described in BTree's pop function.
|
||||
fn remove_leaf(mut self) -> V {
|
||||
@ -686,7 +689,7 @@ mod stack {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, K, V> SearchStack<'a, K, V, KV, LeafOrInternal> {
|
||||
impl<'a, K, V> SearchStack<'a, K, V, handle::KV, handle::LeafOrInternal> {
|
||||
/// Removes the key and value in the top element of the stack, then handles underflows as
|
||||
/// described in BTree's pop function.
|
||||
pub fn remove(self) -> V {
|
||||
@ -703,7 +706,7 @@ mod stack {
|
||||
/// leaves the tree in an inconsistent state that must be repaired by the caller by
|
||||
/// removing the entry in question. Specifically the key-value pair and its successor will
|
||||
/// become swapped.
|
||||
fn into_leaf(mut self) -> SearchStack<'a, K, V, KV, Leaf> {
|
||||
fn into_leaf(mut self) -> SearchStack<'a, K, V, handle::KV, handle::Leaf> {
|
||||
unsafe {
|
||||
let mut top_raw = self.top;
|
||||
let mut top = top_raw.from_raw_mut();
|
||||
@ -757,7 +760,7 @@ mod stack {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, K, V> SearchStack<'a, K, V, Edge, Leaf> {
|
||||
impl<'a, K, V> SearchStack<'a, K, V, handle::Edge, handle::Leaf> {
|
||||
/// Inserts the key and value into the top element in the stack, and if that node has to
|
||||
/// split recursively inserts the split contents into the next element stack until
|
||||
/// splits stop.
|
||||
@ -1332,7 +1335,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use std::prelude::*;
|
||||
use prelude::*;
|
||||
|
||||
use super::{BTreeMap, Occupied, Vacant};
|
||||
|
||||
@ -1534,7 +1537,7 @@ mod test {
|
||||
|
||||
#[cfg(test)]
|
||||
mod bench {
|
||||
use std::prelude::*;
|
||||
use prelude::*;
|
||||
use std::rand::{weak_rng, Rng};
|
||||
use test::{Bencher, black_box};
|
||||
|
||||
|
@ -34,9 +34,9 @@ pub enum InsertionResult<K, V> {
|
||||
/// Represents the result of a search for a key in a single node
|
||||
pub enum SearchResult<NodeRef> {
|
||||
/// The element was found at the given index
|
||||
Found(Handle<NodeRef, KV, LeafOrInternal>),
|
||||
Found(Handle<NodeRef, handle::KV, handle::LeafOrInternal>),
|
||||
/// The element wasn't found, but if it's anywhere, it must be beyond this edge
|
||||
GoDown(Handle<NodeRef, Edge, LeafOrInternal>),
|
||||
GoDown(Handle<NodeRef, handle::Edge, handle::LeafOrInternal>),
|
||||
}
|
||||
|
||||
/// A B-Tree Node. We keep keys/edges/values separate to optimize searching for keys.
|
||||
@ -494,12 +494,16 @@ pub struct Handle<NodeRef, Type, NodeType> {
|
||||
index: uint
|
||||
}
|
||||
|
||||
pub enum KV {}
|
||||
pub enum Edge {}
|
||||
pub mod handle {
|
||||
// Handle types.
|
||||
pub enum KV {}
|
||||
pub enum Edge {}
|
||||
|
||||
pub enum LeafOrInternal {}
|
||||
pub enum Leaf {}
|
||||
pub enum Internal {}
|
||||
// Handle node types.
|
||||
pub enum LeafOrInternal {}
|
||||
pub enum Leaf {}
|
||||
pub enum Internal {}
|
||||
}
|
||||
|
||||
impl<K: Ord, V> Node<K, V> {
|
||||
/// Searches for the given key in the node. If it finds an exact match,
|
||||
@ -625,7 +629,7 @@ impl<K, V, Type, NodeType> Handle<*mut Node<K, V>, Type, NodeType> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, K: 'a, V: 'a> Handle<&'a Node<K, V>, Edge, Internal> {
|
||||
impl<'a, K: 'a, V: 'a> Handle<&'a Node<K, V>, handle::Edge, handle::Internal> {
|
||||
/// Turns the handle into a reference to the edge it points at. This is necessary because the
|
||||
/// returned pointer has a larger lifetime than what would be returned by `edge` or `edge_mut`,
|
||||
/// making it more suitable for moving down a chain of nodes.
|
||||
@ -636,7 +640,7 @@ impl<'a, K: 'a, V: 'a> Handle<&'a Node<K, V>, Edge, Internal> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, K: 'a, V: 'a> Handle<&'a mut Node<K, V>, Edge, Internal> {
|
||||
impl<'a, K: 'a, V: 'a> Handle<&'a mut Node<K, V>, handle::Edge, handle::Internal> {
|
||||
/// Turns the handle into a mutable reference to the edge it points at. This is necessary
|
||||
/// because the returned pointer has a larger lifetime than what would be returned by
|
||||
/// `edge_mut`, making it more suitable for moving down a chain of nodes.
|
||||
@ -647,7 +651,7 @@ impl<'a, K: 'a, V: 'a> Handle<&'a mut Node<K, V>, Edge, Internal> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<K, V, NodeRef: Deref<Node<K, V>>> Handle<NodeRef, Edge, Internal> {
|
||||
impl<K, V, NodeRef: Deref<Node<K, V>>> Handle<NodeRef, handle::Edge, handle::Internal> {
|
||||
// This doesn't exist because there are no uses for it,
|
||||
// but is fine to add, analagous to edge_mut.
|
||||
//
|
||||
@ -657,11 +661,11 @@ impl<K, V, NodeRef: Deref<Node<K, V>>> Handle<NodeRef, Edge, Internal> {
|
||||
}
|
||||
|
||||
pub enum ForceResult<NodeRef, Type> {
|
||||
Leaf(Handle<NodeRef, Type, Leaf>),
|
||||
Internal(Handle<NodeRef, Type, Internal>)
|
||||
Leaf(Handle<NodeRef, Type, handle::Leaf>),
|
||||
Internal(Handle<NodeRef, Type, handle::Internal>)
|
||||
}
|
||||
|
||||
impl<K, V, NodeRef: Deref<Node<K, V>>, Type> Handle<NodeRef, Type, LeafOrInternal> {
|
||||
impl<K, V, NodeRef: Deref<Node<K, V>>, Type> Handle<NodeRef, Type, handle::LeafOrInternal> {
|
||||
/// Figure out whether this handle is pointing to something in a leaf node or to something in
|
||||
/// an internal node, clarifying the type according to the result.
|
||||
pub fn force(self) -> ForceResult<NodeRef, Type> {
|
||||
@ -679,7 +683,7 @@ impl<K, V, NodeRef: Deref<Node<K, V>>, Type> Handle<NodeRef, Type, LeafOrInterna
|
||||
}
|
||||
}
|
||||
|
||||
impl<K, V, NodeRef: DerefMut<Node<K, V>>> Handle<NodeRef, Edge, Leaf> {
|
||||
impl<K, V, NodeRef: DerefMut<Node<K, V>>> Handle<NodeRef, handle::Edge, handle::Leaf> {
|
||||
/// Tries to insert this key-value pair at the given index in this leaf node
|
||||
/// If the node is full, we have to split it.
|
||||
///
|
||||
@ -711,7 +715,7 @@ impl<K, V, NodeRef: DerefMut<Node<K, V>>> Handle<NodeRef, Edge, Leaf> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<K, V, NodeRef: DerefMut<Node<K, V>>> Handle<NodeRef, Edge, Internal> {
|
||||
impl<K, V, NodeRef: DerefMut<Node<K, V>>> Handle<NodeRef, handle::Edge, handle::Internal> {
|
||||
/// Returns a mutable reference to the edge pointed-to by this handle. This should not be
|
||||
/// confused with `node`, which references the parent node of what is returned here.
|
||||
pub fn edge_mut(&mut self) -> &mut Node<K, V> {
|
||||
@ -794,11 +798,11 @@ impl<K, V, NodeRef: DerefMut<Node<K, V>>> Handle<NodeRef, Edge, Internal> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<K, V, NodeRef: DerefMut<Node<K, V>>, NodeType> Handle<NodeRef, Edge, NodeType> {
|
||||
impl<K, V, NodeRef: DerefMut<Node<K, V>>, NodeType> Handle<NodeRef, handle::Edge, NodeType> {
|
||||
/// Gets the handle pointing to the key/value pair just to the left of the pointed-to edge.
|
||||
/// This is unsafe because the handle might point to the first edge in the node, which has no
|
||||
/// pair to its left.
|
||||
unsafe fn left_kv<'a>(&'a mut self) -> Handle<&'a mut Node<K, V>, KV, NodeType> {
|
||||
unsafe fn left_kv<'a>(&'a mut self) -> Handle<&'a mut Node<K, V>, handle::KV, NodeType> {
|
||||
Handle {
|
||||
node: &mut *self.node,
|
||||
index: self.index - 1
|
||||
@ -808,7 +812,7 @@ impl<K, V, NodeRef: DerefMut<Node<K, V>>, NodeType> Handle<NodeRef, Edge, NodeTy
|
||||
/// Gets the handle pointing to the key/value pair just to the right of the pointed-to edge.
|
||||
/// This is unsafe because the handle might point to the last edge in the node, which has no
|
||||
/// pair to its right.
|
||||
unsafe fn right_kv<'a>(&'a mut self) -> Handle<&'a mut Node<K, V>, KV, NodeType> {
|
||||
unsafe fn right_kv<'a>(&'a mut self) -> Handle<&'a mut Node<K, V>, handle::KV, NodeType> {
|
||||
Handle {
|
||||
node: &mut *self.node,
|
||||
index: self.index
|
||||
@ -816,7 +820,7 @@ impl<K, V, NodeRef: DerefMut<Node<K, V>>, NodeType> Handle<NodeRef, Edge, NodeTy
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, K: 'a, V: 'a, NodeType> Handle<&'a Node<K, V>, KV, NodeType> {
|
||||
impl<'a, K: 'a, V: 'a, NodeType> Handle<&'a Node<K, V>, handle::KV, NodeType> {
|
||||
/// Turns the handle into references to the key and value it points at. This is necessary
|
||||
/// because the returned pointers have larger lifetimes than what would be returned by `key`
|
||||
/// or `val`.
|
||||
@ -831,7 +835,7 @@ impl<'a, K: 'a, V: 'a, NodeType> Handle<&'a Node<K, V>, KV, NodeType> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, K: 'a, V: 'a, NodeType> Handle<&'a mut Node<K, V>, KV, NodeType> {
|
||||
impl<'a, K: 'a, V: 'a, NodeType> Handle<&'a mut Node<K, V>, handle::KV, NodeType> {
|
||||
/// Turns the handle into mutable references to the key and value it points at. This is
|
||||
/// necessary because the returned pointers have larger lifetimes than what would be returned
|
||||
/// by `key_mut` or `val_mut`.
|
||||
@ -848,7 +852,7 @@ impl<'a, K: 'a, V: 'a, NodeType> Handle<&'a mut Node<K, V>, KV, NodeType> {
|
||||
/// Convert this handle into one pointing at the edge immediately to the left of the key/value
|
||||
/// pair pointed-to by this handle. This is useful because it returns a reference with larger
|
||||
/// lifetime than `left_edge`.
|
||||
pub fn into_left_edge(self) -> Handle<&'a mut Node<K, V>, Edge, NodeType> {
|
||||
pub fn into_left_edge(self) -> Handle<&'a mut Node<K, V>, handle::Edge, NodeType> {
|
||||
Handle {
|
||||
node: &mut *self.node,
|
||||
index: self.index
|
||||
@ -856,7 +860,8 @@ impl<'a, K: 'a, V: 'a, NodeType> Handle<&'a mut Node<K, V>, KV, NodeType> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, K: 'a, V: 'a, NodeRef: Deref<Node<K, V>> + 'a, NodeType> Handle<NodeRef, KV, NodeType> {
|
||||
impl<'a, K: 'a, V: 'a, NodeRef: Deref<Node<K, V>> + 'a, NodeType> Handle<NodeRef, handle::KV,
|
||||
NodeType> {
|
||||
// These are fine to include, but are currently unneeded.
|
||||
//
|
||||
// /// Returns a reference to the key pointed-to by this handle. This doesn't return a
|
||||
@ -874,7 +879,8 @@ impl<'a, K: 'a, V: 'a, NodeRef: Deref<Node<K, V>> + 'a, NodeType> Handle<NodeRef
|
||||
// }
|
||||
}
|
||||
|
||||
impl<'a, K: 'a, V: 'a, NodeRef: DerefMut<Node<K, V>> + 'a, NodeType> Handle<NodeRef, KV, NodeType> {
|
||||
impl<'a, K: 'a, V: 'a, NodeRef: DerefMut<Node<K, V>> + 'a, NodeType> Handle<NodeRef, handle::KV,
|
||||
NodeType> {
|
||||
/// Returns a mutable reference to the key pointed-to by this handle. This doesn't return a
|
||||
/// reference with a lifetime as large as `into_kv_mut`, but it also does not consume the
|
||||
/// handle.
|
||||
@ -890,10 +896,10 @@ impl<'a, K: 'a, V: 'a, NodeRef: DerefMut<Node<K, V>> + 'a, NodeType> Handle<Node
|
||||
}
|
||||
}
|
||||
|
||||
impl<K, V, NodeRef: DerefMut<Node<K, V>>, NodeType> Handle<NodeRef, KV, NodeType> {
|
||||
impl<K, V, NodeRef: DerefMut<Node<K, V>>, NodeType> Handle<NodeRef, handle::KV, NodeType> {
|
||||
/// Gets the handle pointing to the edge immediately to the left of the key/value pair pointed
|
||||
/// to by this handle.
|
||||
pub fn left_edge<'a>(&'a mut self) -> Handle<&'a mut Node<K, V>, Edge, NodeType> {
|
||||
pub fn left_edge<'a>(&'a mut self) -> Handle<&'a mut Node<K, V>, handle::Edge, NodeType> {
|
||||
Handle {
|
||||
node: &mut *self.node,
|
||||
index: self.index
|
||||
@ -902,7 +908,7 @@ impl<K, V, NodeRef: DerefMut<Node<K, V>>, NodeType> Handle<NodeRef, KV, NodeType
|
||||
|
||||
/// Gets the handle pointing to the edge immediately to the right of the key/value pair pointed
|
||||
/// to by this handle.
|
||||
pub fn right_edge<'a>(&'a mut self) -> Handle<&'a mut Node<K, V>, Edge, NodeType> {
|
||||
pub fn right_edge<'a>(&'a mut self) -> Handle<&'a mut Node<K, V>, handle::Edge, NodeType> {
|
||||
Handle {
|
||||
node: &mut *self.node,
|
||||
index: self.index + 1
|
||||
@ -910,7 +916,7 @@ impl<K, V, NodeRef: DerefMut<Node<K, V>>, NodeType> Handle<NodeRef, KV, NodeType
|
||||
}
|
||||
}
|
||||
|
||||
impl<K, V, NodeRef: DerefMut<Node<K, V>>> Handle<NodeRef, KV, Leaf> {
|
||||
impl<K, V, NodeRef: DerefMut<Node<K, V>>> Handle<NodeRef, handle::KV, handle::Leaf> {
|
||||
/// Removes the key/value pair at the handle's location.
|
||||
///
|
||||
/// # Panics (in debug build)
|
||||
@ -921,7 +927,7 @@ impl<K, V, NodeRef: DerefMut<Node<K, V>>> Handle<NodeRef, KV, Leaf> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<K, V, NodeRef: DerefMut<Node<K, V>>> Handle<NodeRef, KV, Internal> {
|
||||
impl<K, V, NodeRef: DerefMut<Node<K, V>>> Handle<NodeRef, handle::KV, handle::Internal> {
|
||||
/// Steal! Stealing is roughly analogous to a binary tree rotation.
|
||||
/// In this case, we're "rotating" right.
|
||||
unsafe fn steal_rightward(&mut self) {
|
||||
@ -1004,7 +1010,8 @@ impl<K, V> Node<K, V> {
|
||||
/// # Panics (in debug build)
|
||||
///
|
||||
/// Panics if the given index is out of bounds.
|
||||
pub fn kv_handle(&mut self, index: uint) -> Handle<&mut Node<K, V>, KV, LeafOrInternal> {
|
||||
pub fn kv_handle(&mut self, index: uint) -> Handle<&mut Node<K, V>, handle::KV,
|
||||
handle::LeafOrInternal> {
|
||||
// Necessary for correctness, but in a private module
|
||||
debug_assert!(index < self.len(), "kv_handle index out of bounds");
|
||||
Handle {
|
||||
|
@ -726,7 +726,7 @@ impl<'a, T: Ord> Iterator<&'a T> for UnionItems<'a, T> {
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use std::prelude::*;
|
||||
use prelude::*;
|
||||
|
||||
use super::BTreeSet;
|
||||
use std::hash;
|
||||
|
@ -788,14 +788,14 @@ impl<S: Writer, A: Hash<S>> Hash<S> for DList<A> {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::prelude::*;
|
||||
use prelude::*;
|
||||
use std::rand;
|
||||
use std::hash;
|
||||
use std::task::spawn;
|
||||
use test::Bencher;
|
||||
use test;
|
||||
|
||||
use super::{DList, Node, ListInsertion};
|
||||
use vec::Vec;
|
||||
|
||||
pub fn check_links<T>(list: &DList<T>) {
|
||||
let mut len = 0u;
|
||||
|
@ -295,9 +295,9 @@ impl<E:CLike> Extend<E> for EnumSet<E> {
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use std::prelude::*;
|
||||
use self::Foo::*;
|
||||
use std::mem;
|
||||
use prelude::*;
|
||||
use core::mem;
|
||||
|
||||
use super::{EnumSet, CLike};
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
|
||||
#![allow(unknown_features)]
|
||||
#![feature(macro_rules, default_type_params, phase, globs)]
|
||||
#![feature(unsafe_destructor, import_shadowing, slicing_syntax)]
|
||||
#![feature(unsafe_destructor, slicing_syntax)]
|
||||
#![feature(unboxed_closures)]
|
||||
#![no_std]
|
||||
|
||||
@ -95,3 +95,41 @@ mod std {
|
||||
pub use core::kinds; // deriving(Copy)
|
||||
pub use core::hash; // deriving(Hash)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod prelude {
|
||||
// from core.
|
||||
pub use core::borrow::IntoCow;
|
||||
pub use core::char::Char;
|
||||
pub use core::clone::Clone;
|
||||
pub use core::cmp::{PartialEq, Eq, Equiv, PartialOrd, Ord};
|
||||
pub use core::cmp::Ordering::{Less, Equal, Greater};
|
||||
pub use core::iter::range;
|
||||
pub use core::iter::{FromIterator, Extend, IteratorExt};
|
||||
pub use core::iter::{Iterator, DoubleEndedIterator, RandomAccessIterator};
|
||||
pub use core::iter::{IteratorCloneExt, CloneIteratorExt, DoubleEndedIteratorExt};
|
||||
pub use core::iter::{IteratorOrdExt, MutableDoubleEndedIterator, ExactSizeIterator};
|
||||
pub use core::kinds::{Copy, Send, Sized, Sync};
|
||||
pub use core::mem::drop;
|
||||
pub use core::ops::{Drop, Fn, FnMut, FnOnce};
|
||||
pub use core::option::Option;
|
||||
pub use core::option::Option::{Some, None};
|
||||
pub use core::ptr::RawPtr;
|
||||
pub use core::result::Result;
|
||||
pub use core::result::Result::{Ok, Err};
|
||||
|
||||
// in core and collections (may differ).
|
||||
pub use slice::{PartialEqSliceExt, OrdSliceExt};
|
||||
pub use slice::{AsSlice, SliceExt};
|
||||
pub use str::{from_str, Str, StrPrelude};
|
||||
|
||||
// from other crates.
|
||||
pub use alloc::boxed::Box;
|
||||
pub use unicode::char::UnicodeChar;
|
||||
|
||||
// from collections.
|
||||
pub use slice::{CloneSliceExt, VectorVector};
|
||||
pub use str::{IntoMaybeOwned, UnicodeStrPrelude, StrAllocating, StrVector};
|
||||
pub use string::{String, ToString};
|
||||
pub use vec::Vec;
|
||||
}
|
||||
|
@ -1260,18 +1260,17 @@ impl<T: fmt::Show> fmt::Show for RingBuf<T> {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use core::iter;
|
||||
use self::Taggy::*;
|
||||
use self::Taggypar::*;
|
||||
use std::cmp;
|
||||
use prelude::*;
|
||||
use core::cmp;
|
||||
use core::iter;
|
||||
use std::fmt::Show;
|
||||
use std::prelude::*;
|
||||
use std::hash;
|
||||
use test::Bencher;
|
||||
use test;
|
||||
|
||||
use super::RingBuf;
|
||||
use vec::Vec;
|
||||
|
||||
#[test]
|
||||
#[allow(deprecated)]
|
||||
@ -1791,7 +1790,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_from_iter() {
|
||||
use std::iter;
|
||||
use core::iter;
|
||||
let v = vec!(1i,2,3,4,5,6,7);
|
||||
let deq: RingBuf<int> = v.iter().map(|&x| x).collect();
|
||||
let u: Vec<int> = deq.iter().map(|&x| x).collect();
|
||||
|
@ -1343,16 +1343,13 @@ pub mod raw {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::boxed::Box;
|
||||
use std::cell::Cell;
|
||||
use std::default::Default;
|
||||
use std::mem;
|
||||
use std::prelude::*;
|
||||
use prelude::*;
|
||||
use core::cell::Cell;
|
||||
use core::default::Default;
|
||||
use core::mem;
|
||||
use std::rand::{Rng, task_rng};
|
||||
use std::rc::Rc;
|
||||
use std::rt;
|
||||
use slice::*;
|
||||
|
||||
use vec::Vec;
|
||||
use super::ElementSwaps;
|
||||
|
||||
fn square(n: uint) -> uint { n * n }
|
||||
|
||||
@ -2764,14 +2761,12 @@ mod tests {
|
||||
|
||||
#[cfg(test)]
|
||||
mod bench {
|
||||
use std::prelude::*;
|
||||
use prelude::*;
|
||||
use core::mem;
|
||||
use core::ptr;
|
||||
use std::rand::{weak_rng, Rng};
|
||||
use std::mem;
|
||||
use std::ptr;
|
||||
use test::{Bencher, black_box};
|
||||
|
||||
use vec::Vec;
|
||||
|
||||
#[bench]
|
||||
fn iterator(b: &mut Bencher) {
|
||||
// peculiar numbers to stop LLVM from optimising the summation
|
||||
|
@ -51,18 +51,21 @@
|
||||
|
||||
#![doc(primitive = "str")]
|
||||
|
||||
use core::prelude::*;
|
||||
|
||||
pub use self::MaybeOwned::*;
|
||||
use self::RecompositionState::*;
|
||||
use self::DecompositionType::*;
|
||||
|
||||
use core::borrow::{BorrowFrom, Cow, ToOwned};
|
||||
use core::clone::Clone;
|
||||
use core::default::Default;
|
||||
use core::fmt;
|
||||
use core::hash;
|
||||
use core::cmp;
|
||||
use core::iter::AdditiveIterator;
|
||||
use core::char::Char;
|
||||
use core::cmp::{mod, Eq, Equiv, Ord, Ordering, PartialEq, PartialOrd};
|
||||
use core::iter::{range, AdditiveIterator, Iterator, IteratorExt};
|
||||
use core::kinds::Sized;
|
||||
use core::option::Option::{mod, Some, None};
|
||||
use core::slice::{AsSlice, SliceExt};
|
||||
|
||||
use ring_buf::RingBuf;
|
||||
use string::String;
|
||||
@ -834,25 +837,12 @@ impl<'a> StrAllocating for &'a str {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::iter::AdditiveIterator;
|
||||
use std::iter::range;
|
||||
use std::default::Default;
|
||||
use std::char::Char;
|
||||
use std::clone::Clone;
|
||||
use std::cmp::{Ord, PartialOrd, Equiv};
|
||||
use std::cmp::Ordering::{Equal, Greater, Less};
|
||||
use std::option::Option;
|
||||
use std::option::Option::{Some, None};
|
||||
use std::ptr::RawPtr;
|
||||
use std::iter::{Iterator, IteratorExt, DoubleEndedIteratorExt};
|
||||
|
||||
use super::*;
|
||||
use std::slice::{AsSlice, SliceExt};
|
||||
use string::String;
|
||||
use vec::Vec;
|
||||
use slice::CloneSliceExt;
|
||||
|
||||
use unicode::char::UnicodeChar;
|
||||
use prelude::*;
|
||||
use core::default::Default;
|
||||
use core::iter::AdditiveIterator;
|
||||
use super::{eq_slice, from_utf8, is_utf8, is_utf16, raw};
|
||||
use super::truncate_utf16_at_nul;
|
||||
use super::{Owned, Slice};
|
||||
|
||||
#[test]
|
||||
fn test_eq_slice() {
|
||||
@ -1826,7 +1816,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_lev_distance() {
|
||||
use std::char::{ from_u32, MAX };
|
||||
use core::char::{ from_u32, MAX };
|
||||
// Test bytelength agnosticity
|
||||
for c in range(0u32, MAX as u32)
|
||||
.filter_map(|i| from_u32(i))
|
||||
@ -1936,7 +1926,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_graphemes() {
|
||||
use std::iter::order;
|
||||
use core::iter::order;
|
||||
// official Unicode test data
|
||||
// from http://www.unicode.org/Public/UCD/latest/ucd/auxiliary/GraphemeBreakTest.txt
|
||||
let test_same: [(_, &[_]), .. 325] = [
|
||||
@ -2367,7 +2357,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_str_default() {
|
||||
use std::default::Default;
|
||||
use core::default::Default;
|
||||
fn t<S: Default + Str>() {
|
||||
let s: S = Default::default();
|
||||
assert_eq!(s.as_slice(), "");
|
||||
@ -2467,12 +2457,10 @@ mod tests {
|
||||
|
||||
#[cfg(test)]
|
||||
mod bench {
|
||||
use prelude::*;
|
||||
use test::Bencher;
|
||||
use test::black_box;
|
||||
use super::*;
|
||||
use std::iter::{IteratorExt, DoubleEndedIteratorExt};
|
||||
use std::str::StrPrelude;
|
||||
use std::slice::SliceExt;
|
||||
|
||||
#[bench]
|
||||
fn char_iterator(b: &mut Bencher) {
|
||||
|
@ -1040,14 +1040,11 @@ pub mod raw {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::prelude::*;
|
||||
use prelude::*;
|
||||
use test::Bencher;
|
||||
|
||||
use slice::CloneSliceExt;
|
||||
use str::{Str, StrPrelude};
|
||||
use str;
|
||||
use super::{as_string, String, ToString};
|
||||
use vec::Vec;
|
||||
use super::as_string;
|
||||
|
||||
#[test]
|
||||
fn test_as_string() {
|
||||
|
@ -54,7 +54,6 @@ use core::default::Default;
|
||||
use core::fmt;
|
||||
use core::hash::{mod, Hash};
|
||||
use core::kinds::marker::{ContravariantLifetime, InvariantType};
|
||||
use core::kinds::Sized;
|
||||
use core::mem;
|
||||
use core::num::{Int, UnsignedInt};
|
||||
use core::ops;
|
||||
@ -1806,12 +1805,10 @@ impl<'a> fmt::FormatWriter for Vec<u8> {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
extern crate test;
|
||||
|
||||
use std::prelude::*;
|
||||
use std::mem::size_of;
|
||||
use prelude::*;
|
||||
use core::mem::size_of;
|
||||
use test::Bencher;
|
||||
use super::{as_vec, unzip, raw, Vec};
|
||||
use super::{as_vec, unzip, raw};
|
||||
|
||||
struct DropCounter<'a> {
|
||||
count: &'a mut int
|
||||
|
@ -21,7 +21,6 @@ use core::hash::{Hash, Writer};
|
||||
use core::iter;
|
||||
use core::iter::{Enumerate, FilterMap, Map};
|
||||
use core::mem::replace;
|
||||
use core::ops::FnOnce;
|
||||
|
||||
use {vec, slice};
|
||||
use vec::Vec;
|
||||
@ -673,8 +672,7 @@ impl<V> DoubleEndedIterator<(uint, V)> for MoveItems<V> {
|
||||
|
||||
#[cfg(test)]
|
||||
mod test_map {
|
||||
use std::prelude::*;
|
||||
use vec::Vec;
|
||||
use prelude::*;
|
||||
use core::hash::hash;
|
||||
|
||||
use super::VecMap;
|
||||
@ -1047,8 +1045,7 @@ mod test_map {
|
||||
|
||||
#[cfg(test)]
|
||||
mod bench {
|
||||
extern crate test;
|
||||
use self::test::Bencher;
|
||||
use test::Bencher;
|
||||
use super::VecMap;
|
||||
use bench::{insert_rand_n, insert_seq_n, find_rand_n, find_seq_n};
|
||||
|
||||
|
@ -271,14 +271,9 @@ pub fn hash_with_keys<Sized? T: Hash<SipState>>(k0: u64, k1: u64, value: &T) ->
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use test::Bencher;
|
||||
use std::prelude::*;
|
||||
use prelude::*;
|
||||
use std::fmt;
|
||||
|
||||
use str::Str;
|
||||
use string::String;
|
||||
use slice::{AsSlice, SliceExt};
|
||||
use vec::Vec;
|
||||
|
||||
use super::super::{Hash, Writer};
|
||||
use super::{SipState, hash, hash_with_keys};
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
html_root_url = "http://doc.rust-lang.org/nightly/",
|
||||
html_playground_url = "http://play.rust-lang.org/")]
|
||||
|
||||
#![feature(macro_rules, globs, import_shadowing)]
|
||||
#![feature(macro_rules, globs)]
|
||||
pub use self::Piece::*;
|
||||
pub use self::Position::*;
|
||||
pub use self::Alignment::*;
|
||||
|
@ -86,7 +86,6 @@
|
||||
html_root_url = "http://doc.rust-lang.org/nightly/",
|
||||
html_playground_url = "http://play.rust-lang.org/")]
|
||||
#![feature(globs, phase)]
|
||||
#![feature(import_shadowing)]
|
||||
#![feature(unboxed_closures)]
|
||||
#![deny(missing_docs)]
|
||||
|
||||
|
@ -22,7 +22,7 @@
|
||||
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
|
||||
html_root_url = "http://doc.rust-lang.org/nightly/")]
|
||||
|
||||
#![feature(default_type_params, globs, import_shadowing, macro_rules, phase, quote)]
|
||||
#![feature(default_type_params, globs, macro_rules, phase, quote)]
|
||||
#![feature(slicing_syntax, unsafe_destructor)]
|
||||
#![feature(rustc_diagnostic_macros)]
|
||||
#![feature(unboxed_closures)]
|
||||
|
@ -22,7 +22,7 @@ use middle::expr_use_visitor as euv;
|
||||
use middle::mem_categorization::cmt;
|
||||
use middle::pat_util::*;
|
||||
use middle::ty::*;
|
||||
use middle::ty::{mod, Ty};
|
||||
use middle::ty;
|
||||
use std::fmt;
|
||||
use std::iter::AdditiveIterator;
|
||||
use std::iter::range_inclusive;
|
||||
|
@ -14,8 +14,6 @@
|
||||
pub use self::MoveKind::*;
|
||||
|
||||
use borrowck::*;
|
||||
use borrowck::LoanPathKind::{LpVar, LpUpvar, LpDowncast, LpExtend};
|
||||
use borrowck::LoanPathElem::{LpInterior};
|
||||
use rustc::middle::cfg;
|
||||
use rustc::middle::dataflow::DataFlowContext;
|
||||
use rustc::middle::dataflow::BitwiseOperator;
|
||||
|
@ -16,7 +16,7 @@
|
||||
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
|
||||
html_root_url = "http://doc.rust-lang.org/nightly/")]
|
||||
|
||||
#![feature(default_type_params, globs, import_shadowing, macro_rules, phase, quote)]
|
||||
#![feature(default_type_params, globs, macro_rules, phase, quote)]
|
||||
#![feature(slicing_syntax, unsafe_destructor)]
|
||||
#![feature(rustc_diagnostic_macros)]
|
||||
#![feature(unboxed_closures)]
|
||||
|
@ -22,7 +22,7 @@
|
||||
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
|
||||
html_root_url = "http://doc.rust-lang.org/nightly/")]
|
||||
|
||||
#![feature(default_type_params, globs, import_shadowing, macro_rules, phase, quote)]
|
||||
#![feature(default_type_params, globs, macro_rules, phase, quote)]
|
||||
#![feature(slicing_syntax, unsafe_destructor)]
|
||||
#![feature(rustc_diagnostic_macros)]
|
||||
#![feature(unboxed_closures)]
|
||||
|
@ -22,7 +22,7 @@
|
||||
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
|
||||
html_root_url = "http://doc.rust-lang.org/nightly/")]
|
||||
|
||||
#![feature(default_type_params, globs, import_shadowing, macro_rules, phase, quote)]
|
||||
#![feature(default_type_params, globs, macro_rules, phase, quote)]
|
||||
#![feature(slicing_syntax, unsafe_destructor)]
|
||||
#![feature(rustc_diagnostic_macros)]
|
||||
#![feature(unboxed_closures)]
|
||||
|
@ -487,7 +487,7 @@ pub fn trans_fn_ref_with_substs<'blk, 'tcx>(
|
||||
|
||||
let opt_ref_id = match node {
|
||||
ExprId(id) => if id != 0 { Some(id) } else { None },
|
||||
MethodCall(_) => None,
|
||||
MethodCallKey(_) => None,
|
||||
};
|
||||
|
||||
let (val, must_cast) =
|
||||
@ -498,7 +498,7 @@ pub fn trans_fn_ref_with_substs<'blk, 'tcx>(
|
||||
// are subst'd)
|
||||
let ref_ty = match node {
|
||||
ExprId(id) => node_id_type(bcx, id),
|
||||
MethodCall(method_call) => {
|
||||
MethodCallKey(method_call) => {
|
||||
let t = (*bcx.tcx().method_map.borrow())[method_call].ty;
|
||||
monomorphize_type(bcx, t)
|
||||
}
|
||||
|
@ -867,7 +867,7 @@ pub enum ExprOrMethodCall {
|
||||
ExprId(ast::NodeId),
|
||||
|
||||
// Type parameters for a method call like `a.foo::<int>()`
|
||||
MethodCall(ty::MethodCall)
|
||||
MethodCallKey(ty::MethodCall)
|
||||
}
|
||||
|
||||
pub fn node_id_substs<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
@ -879,7 +879,7 @@ pub fn node_id_substs<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
ExprId(id) => {
|
||||
ty::node_id_item_substs(tcx, id).substs
|
||||
}
|
||||
MethodCall(method_call) => {
|
||||
MethodCallKey(method_call) => {
|
||||
(*tcx.method_map.borrow())[method_call].substs.clone()
|
||||
}
|
||||
};
|
||||
|
@ -8,7 +8,7 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use llvm::*;
|
||||
use llvm::ValueRef;
|
||||
use middle::def;
|
||||
use middle::lang_items::{PanicFnLangItem, PanicBoundsCheckFnLangItem};
|
||||
use trans::_match;
|
||||
|
@ -124,7 +124,7 @@ pub fn trans_method_callee<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
bcx: bcx,
|
||||
data: Fn(callee::trans_fn_ref(bcx,
|
||||
did,
|
||||
MethodCall(method_call))),
|
||||
MethodCallKey(method_call))),
|
||||
}
|
||||
}
|
||||
|
||||
@ -344,12 +344,12 @@ fn trans_monomorphized_callee<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
// those from the impl and those from the method:
|
||||
let callee_substs =
|
||||
combine_impl_and_methods_tps(
|
||||
bcx, MethodCall(method_call), vtable_impl.substs);
|
||||
bcx, MethodCallKey(method_call), vtable_impl.substs);
|
||||
|
||||
// translate the function
|
||||
let llfn = trans_fn_ref_with_substs(bcx,
|
||||
mth_id,
|
||||
MethodCall(method_call),
|
||||
MethodCallKey(method_call),
|
||||
callee_substs);
|
||||
|
||||
Callee { bcx: bcx, data: Fn(llfn) }
|
||||
@ -359,7 +359,7 @@ fn trans_monomorphized_callee<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
// after passing through fulfill_obligation
|
||||
let llfn = trans_fn_ref_with_substs(bcx,
|
||||
closure_def_id,
|
||||
MethodCall(method_call),
|
||||
MethodCallKey(method_call),
|
||||
substs);
|
||||
|
||||
Callee {
|
||||
|
@ -71,7 +71,7 @@ This API is completely unstable and subject to change.
|
||||
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
|
||||
html_root_url = "http://doc.rust-lang.org/nightly/")]
|
||||
|
||||
#![feature(default_type_params, globs, import_shadowing, macro_rules, phase, quote)]
|
||||
#![feature(default_type_params, globs, macro_rules, phase, quote)]
|
||||
#![feature(slicing_syntax, unsafe_destructor)]
|
||||
#![feature(rustc_diagnostic_macros)]
|
||||
#![feature(unboxed_closures)]
|
||||
|
@ -633,7 +633,6 @@ mod tests {
|
||||
use prelude::*;
|
||||
use super::*;
|
||||
use char::from_u32;
|
||||
use str::StrPrelude;
|
||||
|
||||
macro_rules! v2ascii {
|
||||
( [$($e:expr),*]) => (&[$(Ascii{chr:$e}),*]);
|
||||
|
@ -315,7 +315,6 @@ macro_rules! bitflags {
|
||||
#[cfg(test)]
|
||||
#[allow(non_upper_case_globals)]
|
||||
mod tests {
|
||||
use kinds::Copy;
|
||||
use hash;
|
||||
use option::Option::{Some, None};
|
||||
use ops::{BitOr, BitAnd, BitXor, Sub, Not};
|
||||
|
@ -67,18 +67,18 @@
|
||||
//! }
|
||||
//! ```
|
||||
|
||||
use string::String;
|
||||
use hash;
|
||||
use core::prelude::*;
|
||||
use libc;
|
||||
|
||||
use fmt;
|
||||
use hash;
|
||||
use kinds::marker;
|
||||
use mem;
|
||||
use core::prelude::*;
|
||||
|
||||
use ptr;
|
||||
use raw::Slice;
|
||||
use slice;
|
||||
use slice::{mod, ImmutableIntSlice};
|
||||
use str;
|
||||
use libc;
|
||||
use string::String;
|
||||
|
||||
|
||||
/// The representation of a C String.
|
||||
///
|
||||
@ -210,7 +210,7 @@ impl CString {
|
||||
#[inline]
|
||||
pub fn as_bytes<'a>(&'a self) -> &'a [u8] {
|
||||
unsafe {
|
||||
mem::transmute(Slice { data: self.buf, len: self.len() + 1 })
|
||||
slice::from_raw_buf(&self.buf, self.len() + 1).as_unsigned()
|
||||
}
|
||||
}
|
||||
|
||||
@ -219,7 +219,7 @@ impl CString {
|
||||
#[inline]
|
||||
pub fn as_bytes_no_nul<'a>(&'a self) -> &'a [u8] {
|
||||
unsafe {
|
||||
mem::transmute(Slice { data: self.buf, len: self.len() })
|
||||
slice::from_raw_buf(&self.buf, self.len()).as_unsigned()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1428,9 +1428,8 @@ mod test_map {
|
||||
|
||||
use super::HashMap;
|
||||
use super::{Occupied, Vacant};
|
||||
use cmp::Equiv;
|
||||
use hash;
|
||||
use iter::{Iterator,range_inclusive,range_step_inclusive};
|
||||
use iter::{range_inclusive, range_step_inclusive};
|
||||
use cell::RefCell;
|
||||
use rand::{weak_rng, Rng};
|
||||
|
||||
|
@ -678,7 +678,6 @@ mod test_set {
|
||||
use prelude::*;
|
||||
|
||||
use super::HashSet;
|
||||
use slice::PartialEqSliceExt;
|
||||
|
||||
#[test]
|
||||
fn test_disjoint() {
|
||||
|
@ -15,21 +15,10 @@
|
||||
#![experimental]
|
||||
#![allow(missing_docs)]
|
||||
|
||||
use clone::Clone;
|
||||
use c_str::ToCStr;
|
||||
use iter::IteratorExt;
|
||||
use prelude::*;
|
||||
use mem;
|
||||
use ops::*;
|
||||
use option::*;
|
||||
use option::Option::{None, Some};
|
||||
use os;
|
||||
use path::{Path,GenericPath};
|
||||
use result::*;
|
||||
use result::Result::{Err, Ok};
|
||||
use slice::{AsSlice,SliceExt};
|
||||
use str;
|
||||
use string::String;
|
||||
use vec::Vec;
|
||||
|
||||
#[allow(missing_copy_implementations)]
|
||||
pub struct DynamicLibrary {
|
||||
@ -213,13 +202,10 @@ mod test {
|
||||
pub mod dl {
|
||||
pub use self::Rtld::*;
|
||||
|
||||
use c_str::{CString, ToCStr};
|
||||
use prelude::*;
|
||||
use c_str::CString;
|
||||
use libc;
|
||||
use ops::FnOnce;
|
||||
use ptr;
|
||||
use result::*;
|
||||
use result::Result::{Err, Ok};
|
||||
use string::String;
|
||||
|
||||
pub unsafe fn open_external<T: ToCStr>(filename: T) -> *mut u8 {
|
||||
filename.with_c_str(|raw_name| {
|
||||
|
@ -409,7 +409,6 @@ mod test {
|
||||
use super::super::{IoResult, EndOfFile};
|
||||
use super::super::mem::MemReader;
|
||||
use self::test::Bencher;
|
||||
use str::StrPrelude;
|
||||
|
||||
/// A type, free to create, primarily intended for benchmarking creation of
|
||||
/// wrappers that, just for construction, don't need a Reader/Writer that
|
||||
|
@ -823,10 +823,6 @@ mod test {
|
||||
use io;
|
||||
use str;
|
||||
use io::fs::*;
|
||||
use path::Path;
|
||||
use io;
|
||||
use ops::Drop;
|
||||
use str::StrPrelude;
|
||||
|
||||
macro_rules! check { ($e:expr) => (
|
||||
match $e {
|
||||
|
@ -398,13 +398,12 @@ impl<'a> Buffer for BufReader<'a> {
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
extern crate test;
|
||||
extern crate "test" as test_crate;
|
||||
use prelude::*;
|
||||
use super::*;
|
||||
use io::*;
|
||||
use io;
|
||||
use self::test::Bencher;
|
||||
use str::StrPrelude;
|
||||
use self::test_crate::Bencher;
|
||||
|
||||
#[test]
|
||||
fn test_vec_writer() {
|
||||
|
@ -225,11 +225,11 @@ fn in_ms_u64(d: Duration) -> u64 {
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
use time::Duration;
|
||||
use task::spawn;
|
||||
use prelude::*;
|
||||
|
||||
use super::Timer;
|
||||
use time::Duration;
|
||||
|
||||
#[test]
|
||||
fn test_io_timer_sleep_simple() {
|
||||
let mut timer = Timer::new().unwrap();
|
||||
|
@ -106,8 +106,7 @@
|
||||
#![allow(unknown_features)]
|
||||
#![feature(macro_rules, globs, linkage, thread_local, asm)]
|
||||
#![feature(default_type_params, phase, lang_items, unsafe_destructor)]
|
||||
#![feature(import_shadowing, slicing_syntax, tuple_indexing)]
|
||||
#![feature(unboxed_closures)]
|
||||
#![feature(slicing_syntax, unboxed_closures)]
|
||||
|
||||
// Don't link to std. We are std.
|
||||
#![no_std]
|
||||
@ -158,7 +157,7 @@ pub use core::unit;
|
||||
pub use core::result;
|
||||
pub use core::option;
|
||||
|
||||
pub use alloc::boxed;
|
||||
#[cfg(not(test))] pub use alloc::boxed;
|
||||
pub use alloc::rc;
|
||||
|
||||
pub use core_collections::slice;
|
||||
|
@ -349,7 +349,6 @@ pub fn to_str_exp_digits(num: f32, dig: uint, upper: bool) -> String {
|
||||
mod tests {
|
||||
use f32::*;
|
||||
use num::*;
|
||||
use num;
|
||||
|
||||
#[test]
|
||||
fn test_min_nan() {
|
||||
@ -364,8 +363,8 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_num() {
|
||||
num::test_num(10f32, 2f32);
|
||||
fn test_num_f32() {
|
||||
test_num(10f32, 2f32);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -357,7 +357,6 @@ pub fn to_str_exp_digits(num: f64, dig: uint, upper: bool) -> String {
|
||||
mod tests {
|
||||
use f64::*;
|
||||
use num::*;
|
||||
use num;
|
||||
|
||||
#[test]
|
||||
fn test_min_nan() {
|
||||
@ -372,8 +371,8 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_num() {
|
||||
num::test_num(10f64, 2f64);
|
||||
fn test_num_f64() {
|
||||
test_num(10f64, 2f64);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -1425,7 +1425,6 @@ mod arch_consts {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use prelude::*;
|
||||
use c_str::ToCStr;
|
||||
use option;
|
||||
use os::{env, getcwd, getenv, make_absolute};
|
||||
use os::{split_paths, join_paths, setenv, unsetenv};
|
||||
|
@ -931,8 +931,6 @@ fn contains_nul<T: BytesContainer>(v: &T) -> bool {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use prelude::*;
|
||||
use super::{GenericPath, PosixPath, WindowsPath};
|
||||
use c_str::ToCStr;
|
||||
|
||||
#[test]
|
||||
fn test_cstring() {
|
||||
|
@ -445,7 +445,6 @@ mod tests {
|
||||
use prelude::*;
|
||||
use super::*;
|
||||
use str;
|
||||
use str::StrPrelude;
|
||||
|
||||
macro_rules! t {
|
||||
(s: $path:expr, $exp:expr) => (
|
||||
|
@ -20,7 +20,6 @@ use core::str;
|
||||
|
||||
use libc::{mod, uintptr_t};
|
||||
use os;
|
||||
use str::{FromStr, from_str, Str};
|
||||
use sync::atomic;
|
||||
|
||||
/// Dynamically inquire about whether we're running under V.
|
||||
@ -66,7 +65,7 @@ pub fn min_stack() -> uint {
|
||||
pub fn default_sched_threads() -> uint {
|
||||
match os::getenv("RUST_THREADS") {
|
||||
Some(nstr) => {
|
||||
let opt_n: Option<uint> = FromStr::from_str(nstr.as_slice());
|
||||
let opt_n: Option<uint> = from_str(nstr.as_slice());
|
||||
match opt_n {
|
||||
Some(n) if n > 0 => n,
|
||||
_ => panic!("`RUST_THREADS` is `{}`, should be a positive integer", nstr)
|
||||
|
@ -153,7 +153,6 @@ mod test {
|
||||
use prelude::*;
|
||||
use sync::Future;
|
||||
use task;
|
||||
use comm::channel;
|
||||
|
||||
#[test]
|
||||
fn test_from_value() {
|
||||
|
@ -131,10 +131,8 @@ fn spawn_in_pool(jobs: Arc<Mutex<Receiver<Thunk>>>) {
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use core::prelude::*;
|
||||
use prelude::*;
|
||||
use super::*;
|
||||
use comm::channel;
|
||||
use iter::range;
|
||||
|
||||
const TEST_TASKS: uint = 4u;
|
||||
|
||||
|
@ -8,8 +8,6 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
pub use sys::mutex::raw;
|
||||
|
||||
use sys::mutex as imp;
|
||||
|
||||
/// An OS-based mutual exclusion lock.
|
||||
|
@ -18,14 +18,11 @@ use io;
|
||||
use prelude::*;
|
||||
|
||||
use io::{FilePermission, Write, UnstableFileStat, Open, FileAccess, FileMode};
|
||||
use io::{IoResult, FileStat, SeekStyle, Reader};
|
||||
use io::{IoResult, FileStat, SeekStyle};
|
||||
use io::{Read, Truncate, SeekCur, SeekSet, ReadWrite, SeekEnd, Append};
|
||||
use result::Result::{Ok, Err};
|
||||
use sys::retry;
|
||||
use sys_common::{keep_going, eof, mkerr_libc};
|
||||
|
||||
pub use path::PosixPath as Path;
|
||||
|
||||
pub type fd_t = libc::c_int;
|
||||
|
||||
pub struct FileDesc {
|
||||
|
@ -16,8 +16,8 @@ use error::{FromError, Error};
|
||||
use fmt;
|
||||
use io::{IoError, IoResult};
|
||||
use libc::{mod, c_int, c_char, c_void};
|
||||
use path::{Path, GenericPath, BytesContainer};
|
||||
use ptr::{mod, RawPtr};
|
||||
use path::BytesContainer;
|
||||
use ptr;
|
||||
use sync::atomic::{AtomicInt, INIT_ATOMIC_INT, SeqCst};
|
||||
use sys::fs::FileDesc;
|
||||
use os;
|
||||
|
@ -20,7 +20,7 @@ use sys::fs::FileDesc;
|
||||
use sys::{set_nonblocking, wouldblock};
|
||||
use sys;
|
||||
use sys_common;
|
||||
use sys_common::net::*;
|
||||
use sys_common::net;
|
||||
|
||||
pub use sys_common::net::TcpStream;
|
||||
|
||||
@ -34,17 +34,19 @@ pub struct TcpListener {
|
||||
|
||||
impl TcpListener {
|
||||
pub fn bind(addr: ip::SocketAddr) -> IoResult<TcpListener> {
|
||||
let fd = try!(socket(addr, libc::SOCK_STREAM));
|
||||
let fd = try!(net::socket(addr, libc::SOCK_STREAM));
|
||||
let ret = TcpListener { inner: FileDesc::new(fd, true) };
|
||||
|
||||
let mut storage = unsafe { mem::zeroed() };
|
||||
let len = addr_to_sockaddr(addr, &mut storage);
|
||||
let len = net::addr_to_sockaddr(addr, &mut storage);
|
||||
let addrp = &storage as *const _ as *const libc::sockaddr;
|
||||
|
||||
// On platforms with Berkeley-derived sockets, this allows
|
||||
// to quickly rebind a socket, without needing to wait for
|
||||
// the OS to clean up the previous one.
|
||||
try!(setsockopt(fd, libc::SOL_SOCKET, libc::SO_REUSEADDR, 1 as libc::c_int));
|
||||
try!(net::setsockopt(fd, libc::SOL_SOCKET,
|
||||
libc::SO_REUSEADDR,
|
||||
1 as libc::c_int));
|
||||
|
||||
|
||||
match unsafe { libc::bind(fd, addrp, len) } {
|
||||
@ -77,7 +79,7 @@ impl TcpListener {
|
||||
}
|
||||
|
||||
pub fn socket_name(&mut self) -> IoResult<ip::SocketAddr> {
|
||||
sockname(self.fd(), libc::getsockname)
|
||||
net::sockname(self.fd(), libc::getsockname)
|
||||
}
|
||||
}
|
||||
|
||||
@ -121,15 +123,15 @@ impl TcpAcceptor {
|
||||
-1 => return Err(last_net_error()),
|
||||
fd => return Ok(TcpStream::new(fd as sock_t)),
|
||||
}
|
||||
try!(await(&[self.fd(), self.inner.reader.fd()],
|
||||
deadline, Readable));
|
||||
try!(net::await(&[self.fd(), self.inner.reader.fd()],
|
||||
deadline, net::Readable));
|
||||
}
|
||||
|
||||
Err(sys_common::eof())
|
||||
}
|
||||
|
||||
pub fn socket_name(&mut self) -> IoResult<ip::SocketAddr> {
|
||||
sockname(self.fd(), libc::getsockname)
|
||||
net::sockname(self.fd(), libc::getsockname)
|
||||
}
|
||||
|
||||
pub fn set_timeout(&mut self, timeout: Option<u64>) {
|
||||
|
@ -10,7 +10,6 @@
|
||||
|
||||
use cell::UnsafeCell;
|
||||
use libc::{mod, DWORD};
|
||||
use libc;
|
||||
use os;
|
||||
use sys::mutex::{mod, Mutex};
|
||||
use sys::sync as ffi;
|
||||
|
@ -26,10 +26,9 @@ use sys;
|
||||
use sys_common::{keep_going, eof, mkerr_libc};
|
||||
|
||||
use io::{FilePermission, Write, UnstableFileStat, Open, FileAccess, FileMode};
|
||||
use io::{IoResult, IoError, FileStat, SeekStyle, Seek, Writer, Reader};
|
||||
use io::{IoResult, IoError, FileStat, SeekStyle};
|
||||
use io::{Read, Truncate, SeekCur, SeekSet, ReadWrite, SeekEnd, Append};
|
||||
|
||||
pub use path::WindowsPath as Path;
|
||||
pub type fd_t = libc::c_int;
|
||||
|
||||
pub struct FileDesc {
|
||||
|
@ -20,12 +20,10 @@ use io::{IoResult, IoError};
|
||||
use libc::{c_int, c_char, c_void};
|
||||
use libc;
|
||||
use os;
|
||||
use path::{Path, GenericPath, BytesContainer};
|
||||
use ptr::{mod, RawPtr};
|
||||
use path::BytesContainer;
|
||||
use ptr;
|
||||
use sync::atomic::{AtomicInt, INIT_ATOMIC_INT, SeqCst};
|
||||
use sys::fs::FileDesc;
|
||||
use option::Option;
|
||||
use option::Option::{Some, None};
|
||||
use slice;
|
||||
|
||||
use os::TMPBUF_SZ;
|
||||
|
@ -29,7 +29,6 @@ use sys_common::helper_thread::Helper;
|
||||
use sys_common::{AsInner, mkerr_libc, timeout};
|
||||
|
||||
use io::fs::PathExtensions;
|
||||
use string::String;
|
||||
|
||||
pub use sys_common::ProcessConfig;
|
||||
|
||||
|
@ -18,8 +18,7 @@ use super::{last_error, last_net_error, retry, sock_t};
|
||||
use sync::{Arc, atomic};
|
||||
use sys::fs::FileDesc;
|
||||
use sys::{mod, c, set_nonblocking, wouldblock, timer};
|
||||
use sys_common::{mod, timeout, eof};
|
||||
use sys_common::net::*;
|
||||
use sys_common::{mod, timeout, eof, net};
|
||||
|
||||
pub use sys_common::net::TcpStream;
|
||||
|
||||
@ -54,11 +53,11 @@ impl TcpListener {
|
||||
pub fn bind(addr: ip::SocketAddr) -> IoResult<TcpListener> {
|
||||
sys::init_net();
|
||||
|
||||
let sock = try!(socket(addr, libc::SOCK_STREAM));
|
||||
let sock = try!(net::socket(addr, libc::SOCK_STREAM));
|
||||
let ret = TcpListener { sock: sock };
|
||||
|
||||
let mut storage = unsafe { mem::zeroed() };
|
||||
let len = addr_to_sockaddr(addr, &mut storage);
|
||||
let len = net::addr_to_sockaddr(addr, &mut storage);
|
||||
let addrp = &storage as *const _ as *const libc::sockaddr;
|
||||
|
||||
match unsafe { libc::bind(sock, addrp, len) } {
|
||||
@ -95,7 +94,7 @@ impl TcpListener {
|
||||
}
|
||||
|
||||
pub fn socket_name(&mut self) -> IoResult<ip::SocketAddr> {
|
||||
sockname(self.socket(), libc::getsockname)
|
||||
net::sockname(self.socket(), libc::getsockname)
|
||||
}
|
||||
}
|
||||
|
||||
@ -195,7 +194,7 @@ impl TcpAcceptor {
|
||||
}
|
||||
|
||||
pub fn socket_name(&mut self) -> IoResult<ip::SocketAddr> {
|
||||
sockname(self.socket(), libc::getsockname)
|
||||
net::sockname(self.socket(), libc::getsockname)
|
||||
}
|
||||
|
||||
pub fn set_timeout(&mut self, timeout: Option<u64>) {
|
||||
|
@ -124,13 +124,17 @@
|
||||
//!
|
||||
//! * It can be implemented highly efficiently on many platforms.
|
||||
|
||||
use core::prelude::*;
|
||||
|
||||
use any::Any;
|
||||
use borrow::IntoCow;
|
||||
use boxed::Box;
|
||||
use cell::UnsafeCell;
|
||||
use clone::Clone;
|
||||
use kinds::Send;
|
||||
use ops::{Drop, FnOnce};
|
||||
use option::Option::{mod, Some, None};
|
||||
use result::Result::{Err, Ok};
|
||||
use sync::{Mutex, Condvar, Arc};
|
||||
use str::Str;
|
||||
use string::String;
|
||||
use rt::{mod, unwind};
|
||||
use io::{Writer, stdio};
|
||||
@ -424,13 +428,11 @@ impl<T: Send> Drop for JoinGuard<T> {
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use prelude::*;
|
||||
use any::{Any, AnyRefExt};
|
||||
use boxed::BoxAny;
|
||||
use prelude::*;
|
||||
use result::Result::{Ok, Err};
|
||||
use result;
|
||||
use std::io::{ChanReader, ChanWriter};
|
||||
use string::String;
|
||||
use thunk::Thunk;
|
||||
use super::{Thread, Builder};
|
||||
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
#![allow(unknown_features)]
|
||||
#![feature(macro_rules, globs, default_type_params, phase, slicing_syntax)]
|
||||
#![feature(quote, unsafe_destructor, import_shadowing)]
|
||||
#![feature(quote, unsafe_destructor)]
|
||||
#![feature(unboxed_closures)]
|
||||
|
||||
extern crate arena;
|
||||
|
@ -745,8 +745,7 @@ mod test {
|
||||
use owned_slice::OwnedSlice;
|
||||
use ast;
|
||||
use abi;
|
||||
use attr;
|
||||
use attr::AttrMetaMethods;
|
||||
use attr::{first_attr_value_str_by_name, AttrMetaMethods};
|
||||
use parse::parser::Parser;
|
||||
use parse::token::{str_to_ident};
|
||||
use print::pprust::view_item_to_string;
|
||||
@ -1195,7 +1194,7 @@ mod test {
|
||||
let name = "<source>".to_string();
|
||||
let source = "/// doc comment\r\nfn foo() {}".to_string();
|
||||
let item = parse_item_from_source_str(name.clone(), source, Vec::new(), &sess).unwrap();
|
||||
let doc = attr::first_attr_value_str_by_name(item.attrs.as_slice(), "doc").unwrap();
|
||||
let doc = first_attr_value_str_by_name(item.attrs.as_slice(), "doc").unwrap();
|
||||
assert_eq!(doc.get(), "/// doc comment");
|
||||
|
||||
let source = "/// doc comment\r\n/// line 2\r\nfn foo() {}".to_string();
|
||||
@ -1207,7 +1206,7 @@ mod test {
|
||||
|
||||
let source = "/** doc comment\r\n * with CRLF */\r\nfn foo() {}".to_string();
|
||||
let item = parse_item_from_source_str(name, source, Vec::new(), &sess).unwrap();
|
||||
let doc = attr::first_attr_value_str_by_name(item.attrs.as_slice(), "doc").unwrap();
|
||||
let doc = first_attr_value_str_by_name(item.attrs.as_slice(), "doc").unwrap();
|
||||
assert_eq!(doc.get(), "/** doc comment\n * with CRLF */");
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user