std: Drop Total from Total{Eq,Ord}
This completes the last stage of the renaming of the comparison hierarchy of traits. This change renames TotalEq to Eq and TotalOrd to Ord. In the future the new Eq/Ord will be filled out with their appropriate methods, but for now this change is purely a renaming change. [breaking-change]
This commit is contained in:
parent
c605c2b57b
commit
bba701c59d
@ -12,7 +12,7 @@
|
||||
|
||||
use core::any::{Any, AnyRefExt};
|
||||
use core::clone::Clone;
|
||||
use core::cmp::{PartialEq, PartialOrd, TotalEq, TotalOrd, Ordering};
|
||||
use core::cmp::{PartialEq, PartialOrd, Eq, Ord, Ordering};
|
||||
use core::default::Default;
|
||||
use core::fmt;
|
||||
use core::intrinsics;
|
||||
@ -67,11 +67,11 @@ impl<T:PartialOrd> PartialOrd for Box<T> {
|
||||
#[inline]
|
||||
fn gt(&self, other: &Box<T>) -> bool { *(*self) > *(*other) }
|
||||
}
|
||||
impl<T: TotalOrd> TotalOrd for Box<T> {
|
||||
impl<T: Ord> Ord for Box<T> {
|
||||
#[inline]
|
||||
fn cmp(&self, other: &Box<T>) -> Ordering { (**self).cmp(*other) }
|
||||
}
|
||||
impl<T: TotalEq> TotalEq for Box<T> {}
|
||||
impl<T: Eq> Eq for Box<T> {}
|
||||
|
||||
/// Extension methods for an owning `Any` trait object
|
||||
pub trait AnyOwnExt {
|
||||
|
@ -26,7 +26,7 @@ pointers, and then storing the parent pointers as `Weak` pointers.
|
||||
use core::mem::transmute;
|
||||
use core::cell::Cell;
|
||||
use core::clone::Clone;
|
||||
use core::cmp::{PartialEq, PartialOrd, TotalEq, TotalOrd, Ordering};
|
||||
use core::cmp::{PartialEq, PartialOrd, Eq, Ord, Ordering};
|
||||
use core::kinds::marker;
|
||||
use core::ops::{Deref, Drop};
|
||||
use core::option::{Option, Some, None};
|
||||
@ -157,7 +157,7 @@ impl<T: PartialEq> PartialEq for Rc<T> {
|
||||
fn ne(&self, other: &Rc<T>) -> bool { **self != **other }
|
||||
}
|
||||
|
||||
impl<T: TotalEq> TotalEq for Rc<T> {}
|
||||
impl<T: Eq> Eq for Rc<T> {}
|
||||
|
||||
impl<T: PartialOrd> PartialOrd for Rc<T> {
|
||||
#[inline(always)]
|
||||
@ -173,7 +173,7 @@ impl<T: PartialOrd> PartialOrd for Rc<T> {
|
||||
fn ge(&self, other: &Rc<T>) -> bool { **self >= **other }
|
||||
}
|
||||
|
||||
impl<T: TotalOrd> TotalOrd for Rc<T> {
|
||||
impl<T: Ord> Ord for Rc<T> {
|
||||
#[inline]
|
||||
fn cmp(&self, other: &Rc<T>) -> Ordering { (**self).cmp(&**other) }
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ pub struct BTree<K, V> {
|
||||
upper_bound: uint
|
||||
}
|
||||
|
||||
impl<K: TotalOrd, V> BTree<K, V> {
|
||||
impl<K: Ord, V> BTree<K, V> {
|
||||
|
||||
///Returns new BTree with root node (leaf) and user-supplied lower bound
|
||||
///The lower bound applies to every node except the root node.
|
||||
@ -59,7 +59,7 @@ impl<K: TotalOrd, V> BTree<K, V> {
|
||||
//We would probably want to remove the dependence on the Clone trait in the future.
|
||||
//It is here as a crutch to ensure values can be passed around through the tree's nodes
|
||||
//especially during insertions and deletions.
|
||||
impl<K: Clone + TotalOrd, V: Clone> BTree<K, V> {
|
||||
impl<K: Clone + Ord, V: Clone> BTree<K, V> {
|
||||
///Returns the value of a given key, which may not exist in the tree.
|
||||
///Calls the root node's get method.
|
||||
pub fn get(self, k: K) -> Option<V> {
|
||||
@ -84,7 +84,7 @@ impl<K: Clone + TotalOrd, V: Clone> BTree<K, V> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<K: Clone + TotalOrd, V: Clone> Clone for BTree<K, V> {
|
||||
impl<K: Clone + Ord, V: Clone> Clone for BTree<K, V> {
|
||||
///Implements the Clone trait for the BTree.
|
||||
///Uses a helper function/constructor to produce a new BTree.
|
||||
fn clone(&self) -> BTree<K, V> {
|
||||
@ -92,28 +92,28 @@ impl<K: Clone + TotalOrd, V: Clone> Clone for BTree<K, V> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<K: TotalOrd, V: TotalEq> PartialEq for BTree<K, V> {
|
||||
impl<K: Ord, V: Eq> PartialEq for BTree<K, V> {
|
||||
fn eq(&self, other: &BTree<K, V>) -> bool {
|
||||
self.root.cmp(&other.root) == Equal
|
||||
}
|
||||
}
|
||||
|
||||
impl<K: TotalOrd, V: TotalEq> TotalEq for BTree<K, V> {}
|
||||
impl<K: Ord, V: Eq> Eq for BTree<K, V> {}
|
||||
|
||||
impl<K: TotalOrd, V: TotalEq> PartialOrd for BTree<K, V> {
|
||||
impl<K: Ord, V: Eq> PartialOrd for BTree<K, V> {
|
||||
fn lt(&self, other: &BTree<K, V>) -> bool {
|
||||
self.cmp(other) == Less
|
||||
}
|
||||
}
|
||||
|
||||
impl<K: TotalOrd, V: TotalEq> TotalOrd for BTree<K, V> {
|
||||
impl<K: Ord, V: Eq> Ord for BTree<K, V> {
|
||||
///Returns an ordering based on the root nodes of each BTree.
|
||||
fn cmp(&self, other: &BTree<K, V>) -> Ordering {
|
||||
self.root.cmp(&other.root)
|
||||
}
|
||||
}
|
||||
|
||||
impl<K: fmt::Show + TotalOrd, V: fmt::Show> fmt::Show for BTree<K, V> {
|
||||
impl<K: fmt::Show + Ord, V: fmt::Show> fmt::Show for BTree<K, V> {
|
||||
///Returns a string representation of the BTree
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
self.root.fmt(f)
|
||||
@ -133,7 +133,7 @@ enum Node<K, V> {
|
||||
|
||||
|
||||
//Node functions/methods
|
||||
impl<K: TotalOrd, V> Node<K, V> {
|
||||
impl<K: Ord, V> Node<K, V> {
|
||||
///Creates a new leaf node given a vector of elements.
|
||||
fn new_leaf(vec: Vec<LeafElt<K, V>>) -> Node<K,V> {
|
||||
LeafNode(Leaf::new(vec))
|
||||
@ -164,7 +164,7 @@ impl<K: TotalOrd, V> Node<K, V> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<K: Clone + TotalOrd, V: Clone> Node<K, V> {
|
||||
impl<K: Clone + Ord, V: Clone> Node<K, V> {
|
||||
///Returns the corresponding value to the provided key.
|
||||
///get() is called in different ways on a branch or a leaf.
|
||||
fn get(&self, k: K) -> Option<V> {
|
||||
@ -183,7 +183,7 @@ impl<K: Clone + TotalOrd, V: Clone> Node<K, V> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<K: Clone + TotalOrd, V: Clone> Clone for Node<K, V> {
|
||||
impl<K: Clone + Ord, V: Clone> Clone for Node<K, V> {
|
||||
///Returns a new node based on whether or not it is a branch or a leaf.
|
||||
fn clone(&self) -> Node<K, V> {
|
||||
match *self {
|
||||
@ -198,7 +198,7 @@ impl<K: Clone + TotalOrd, V: Clone> Clone for Node<K, V> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<K: TotalOrd, V: TotalEq> PartialEq for Node<K, V> {
|
||||
impl<K: Ord, V: Eq> PartialEq for Node<K, V> {
|
||||
fn eq(&self, other: &Node<K, V>) -> bool {
|
||||
match *self{
|
||||
BranchNode(ref branch) => {
|
||||
@ -220,16 +220,16 @@ impl<K: TotalOrd, V: TotalEq> PartialEq for Node<K, V> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<K: TotalOrd, V: TotalEq> TotalEq for Node<K, V> {}
|
||||
impl<K: Ord, V: Eq> Eq for Node<K, V> {}
|
||||
|
||||
impl<K: TotalOrd, V: TotalEq> PartialOrd for Node<K, V> {
|
||||
impl<K: Ord, V: Eq> PartialOrd for Node<K, V> {
|
||||
fn lt(&self, other: &Node<K, V>) -> bool {
|
||||
self.cmp(other) == Less
|
||||
}
|
||||
}
|
||||
|
||||
impl<K: TotalOrd, V: TotalEq> TotalOrd for Node<K, V> {
|
||||
///Implementation of TotalOrd for Nodes.
|
||||
impl<K: Ord, V: Eq> Ord for Node<K, V> {
|
||||
///Implementation of Ord for Nodes.
|
||||
fn cmp(&self, other: &Node<K, V>) -> Ordering {
|
||||
match *self {
|
||||
LeafNode(ref leaf) => {
|
||||
@ -248,7 +248,7 @@ impl<K: TotalOrd, V: TotalEq> TotalOrd for Node<K, V> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<K: fmt::Show + TotalOrd, V: fmt::Show> fmt::Show for Node<K, V> {
|
||||
impl<K: fmt::Show + Ord, V: fmt::Show> fmt::Show for Node<K, V> {
|
||||
///Returns a string representation of a Node.
|
||||
///Will iterate over the Node and show "Key: x, value: y, child: () // "
|
||||
///for all elements in the Node. "Child" only exists if the Node contains
|
||||
@ -275,7 +275,7 @@ struct Branch<K, V> {
|
||||
}
|
||||
|
||||
|
||||
impl<K: TotalOrd, V> Leaf<K, V> {
|
||||
impl<K: Ord, V> Leaf<K, V> {
|
||||
///Creates a new Leaf from a vector of LeafElts.
|
||||
fn new(vec: Vec<LeafElt<K, V>>) -> Leaf<K, V> {
|
||||
Leaf {
|
||||
@ -335,7 +335,7 @@ impl<K: TotalOrd, V> Leaf<K, V> {
|
||||
}
|
||||
|
||||
|
||||
impl<K: Clone + TotalOrd, V: Clone> Leaf<K, V> {
|
||||
impl<K: Clone + Ord, V: Clone> Leaf<K, V> {
|
||||
///Returns the corresponding value to the supplied key.
|
||||
fn get(&self, k: K) -> Option<V> {
|
||||
for s in self.elts.iter() {
|
||||
@ -386,28 +386,28 @@ impl<K: Clone + TotalOrd, V: Clone> Leaf<K, V> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<K: Clone + TotalOrd, V: Clone> Clone for Leaf<K, V> {
|
||||
impl<K: Clone + Ord, V: Clone> Clone for Leaf<K, V> {
|
||||
///Returns a new Leaf with the same elts.
|
||||
fn clone(&self) -> Leaf<K, V> {
|
||||
Leaf::new(self.elts.clone())
|
||||
}
|
||||
}
|
||||
|
||||
impl<K: TotalOrd, V: TotalEq> PartialEq for Leaf<K, V> {
|
||||
impl<K: Ord, V: Eq> PartialEq for Leaf<K, V> {
|
||||
fn eq(&self, other: &Leaf<K, V>) -> bool {
|
||||
self.elts == other.elts
|
||||
}
|
||||
}
|
||||
|
||||
impl<K: TotalOrd, V: TotalEq> TotalEq for Leaf<K, V> {}
|
||||
impl<K: Ord, V: Eq> Eq for Leaf<K, V> {}
|
||||
|
||||
impl<K: TotalOrd, V: TotalEq> PartialOrd for Leaf<K, V> {
|
||||
impl<K: Ord, V: Eq> PartialOrd for Leaf<K, V> {
|
||||
fn lt(&self, other: &Leaf<K, V>) -> bool {
|
||||
self.cmp(other) == Less
|
||||
}
|
||||
}
|
||||
|
||||
impl<K: TotalOrd, V: TotalEq> TotalOrd for Leaf<K, V> {
|
||||
impl<K: Ord, V: Eq> Ord for Leaf<K, V> {
|
||||
///Returns an ordering based on the first element of each Leaf.
|
||||
fn cmp(&self, other: &Leaf<K, V>) -> Ordering {
|
||||
if self.elts.len() > other.elts.len() {
|
||||
@ -421,7 +421,7 @@ impl<K: TotalOrd, V: TotalEq> TotalOrd for Leaf<K, V> {
|
||||
}
|
||||
|
||||
|
||||
impl<K: fmt::Show + TotalOrd, V: fmt::Show> fmt::Show for Leaf<K, V> {
|
||||
impl<K: fmt::Show + Ord, V: fmt::Show> fmt::Show for Leaf<K, V> {
|
||||
///Returns a string representation of a Leaf.
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
for (i, s) in self.elts.iter().enumerate() {
|
||||
@ -433,7 +433,7 @@ impl<K: fmt::Show + TotalOrd, V: fmt::Show> fmt::Show for Leaf<K, V> {
|
||||
}
|
||||
|
||||
|
||||
impl<K: TotalOrd, V> Branch<K, V> {
|
||||
impl<K: Ord, V> Branch<K, V> {
|
||||
///Creates a new Branch from a vector of BranchElts and a rightmost child (a node).
|
||||
fn new(vec: Vec<BranchElt<K, V>>, right: Box<Node<K, V>>)
|
||||
-> Branch<K, V> {
|
||||
@ -492,7 +492,7 @@ impl<K: TotalOrd, V> Branch<K, V> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<K: Clone + TotalOrd, V: Clone> Branch<K, V> {
|
||||
impl<K: Clone + Ord, V: Clone> Branch<K, V> {
|
||||
///Returns the corresponding value to the supplied key.
|
||||
///If the key is not there, find the child that might hold it.
|
||||
fn get(&self, k: K) -> Option<V> {
|
||||
@ -616,28 +616,28 @@ impl<K: Clone + TotalOrd, V: Clone> Branch<K, V> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<K: Clone + TotalOrd, V: Clone> Clone for Branch<K, V> {
|
||||
impl<K: Clone + Ord, V: Clone> Clone for Branch<K, V> {
|
||||
///Returns a new branch using the clone methods of the Branch's internal variables.
|
||||
fn clone(&self) -> Branch<K, V> {
|
||||
Branch::new(self.elts.clone(), self.rightmost_child.clone())
|
||||
}
|
||||
}
|
||||
|
||||
impl<K: TotalOrd, V: TotalEq> PartialEq for Branch<K, V> {
|
||||
impl<K: Ord, V: Eq> PartialEq for Branch<K, V> {
|
||||
fn eq(&self, other: &Branch<K, V>) -> bool {
|
||||
self.elts == other.elts
|
||||
}
|
||||
}
|
||||
|
||||
impl<K: TotalOrd, V: TotalEq> TotalEq for Branch<K, V> {}
|
||||
impl<K: Ord, V: Eq> Eq for Branch<K, V> {}
|
||||
|
||||
impl<K: TotalOrd, V: TotalEq> PartialOrd for Branch<K, V> {
|
||||
impl<K: Ord, V: Eq> PartialOrd for Branch<K, V> {
|
||||
fn lt(&self, other: &Branch<K, V>) -> bool {
|
||||
self.cmp(other) == Less
|
||||
}
|
||||
}
|
||||
|
||||
impl<K: TotalOrd, V: TotalEq> TotalOrd for Branch<K, V> {
|
||||
impl<K: Ord, V: Eq> Ord for Branch<K, V> {
|
||||
///Compares the first elements of two branches to determine an ordering
|
||||
fn cmp(&self, other: &Branch<K, V>) -> Ordering {
|
||||
if self.elts.len() > other.elts.len() {
|
||||
@ -650,7 +650,7 @@ impl<K: TotalOrd, V: TotalEq> TotalOrd for Branch<K, V> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<K: fmt::Show + TotalOrd, V: fmt::Show> fmt::Show for Branch<K, V> {
|
||||
impl<K: fmt::Show + Ord, V: fmt::Show> fmt::Show for Branch<K, V> {
|
||||
///Returns a string representation of a Branch.
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
for (i, s) in self.elts.iter().enumerate() {
|
||||
@ -674,7 +674,7 @@ struct BranchElt<K, V> {
|
||||
value: V
|
||||
}
|
||||
|
||||
impl<K: TotalOrd, V> LeafElt<K, V> {
|
||||
impl<K: Ord, V> LeafElt<K, V> {
|
||||
///Creates a new LeafElt from a supplied key-value pair.
|
||||
fn new(k: K, v: V) -> LeafElt<K, V> {
|
||||
LeafElt {
|
||||
@ -684,42 +684,42 @@ impl<K: TotalOrd, V> LeafElt<K, V> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<K: Clone + TotalOrd, V: Clone> Clone for LeafElt<K, V> {
|
||||
impl<K: Clone + Ord, V: Clone> Clone for LeafElt<K, V> {
|
||||
///Returns a new LeafElt by cloning the key and value.
|
||||
fn clone(&self) -> LeafElt<K, V> {
|
||||
LeafElt::new(self.key.clone(), self.value.clone())
|
||||
}
|
||||
}
|
||||
|
||||
impl<K: TotalOrd, V: TotalEq> PartialEq for LeafElt<K, V> {
|
||||
impl<K: Ord, V: Eq> PartialEq for LeafElt<K, V> {
|
||||
fn eq(&self, other: &LeafElt<K, V>) -> bool {
|
||||
self.key == other.key && self.value == other.value
|
||||
}
|
||||
}
|
||||
|
||||
impl<K: TotalOrd, V: TotalEq> TotalEq for LeafElt<K, V> {}
|
||||
impl<K: Ord, V: Eq> Eq for LeafElt<K, V> {}
|
||||
|
||||
impl<K: TotalOrd, V: TotalEq> PartialOrd for LeafElt<K, V> {
|
||||
impl<K: Ord, V: Eq> PartialOrd for LeafElt<K, V> {
|
||||
fn lt(&self, other: &LeafElt<K, V>) -> bool {
|
||||
self.cmp(other) == Less
|
||||
}
|
||||
}
|
||||
|
||||
impl<K: TotalOrd, V: TotalEq> TotalOrd for LeafElt<K, V> {
|
||||
impl<K: Ord, V: Eq> Ord for LeafElt<K, V> {
|
||||
///Returns an ordering based on the keys of the LeafElts.
|
||||
fn cmp(&self, other: &LeafElt<K, V>) -> Ordering {
|
||||
self.key.cmp(&other.key)
|
||||
}
|
||||
}
|
||||
|
||||
impl<K: fmt::Show + TotalOrd, V: fmt::Show> fmt::Show for LeafElt<K, V> {
|
||||
impl<K: fmt::Show + Ord, V: fmt::Show> fmt::Show for LeafElt<K, V> {
|
||||
///Returns a string representation of a LeafElt.
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "Key: {}, value: {};", self.key, self.value)
|
||||
}
|
||||
}
|
||||
|
||||
impl<K: TotalOrd, V> BranchElt<K, V> {
|
||||
impl<K: Ord, V> BranchElt<K, V> {
|
||||
///Creates a new BranchElt from a supplied key, value, and left child.
|
||||
fn new(k: K, v: V, n: Box<Node<K, V>>) -> BranchElt<K, V> {
|
||||
BranchElt {
|
||||
@ -731,7 +731,7 @@ impl<K: TotalOrd, V> BranchElt<K, V> {
|
||||
}
|
||||
|
||||
|
||||
impl<K: Clone + TotalOrd, V: Clone> Clone for BranchElt<K, V> {
|
||||
impl<K: Clone + Ord, V: Clone> Clone for BranchElt<K, V> {
|
||||
///Returns a new BranchElt by cloning the key, value, and left child.
|
||||
fn clone(&self) -> BranchElt<K, V> {
|
||||
BranchElt::new(self.key.clone(),
|
||||
@ -740,28 +740,28 @@ impl<K: Clone + TotalOrd, V: Clone> Clone for BranchElt<K, V> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<K: TotalOrd, V: TotalEq> PartialEq for BranchElt<K, V>{
|
||||
impl<K: Ord, V: Eq> PartialEq for BranchElt<K, V>{
|
||||
fn eq(&self, other: &BranchElt<K, V>) -> bool {
|
||||
self.key == other.key && self.value == other.value
|
||||
}
|
||||
}
|
||||
|
||||
impl<K: TotalOrd, V: TotalEq> TotalEq for BranchElt<K, V>{}
|
||||
impl<K: Ord, V: Eq> Eq for BranchElt<K, V>{}
|
||||
|
||||
impl<K: TotalOrd, V: TotalEq> PartialOrd for BranchElt<K, V> {
|
||||
impl<K: Ord, V: Eq> PartialOrd for BranchElt<K, V> {
|
||||
fn lt(&self, other: &BranchElt<K, V>) -> bool {
|
||||
self.cmp(other) == Less
|
||||
}
|
||||
}
|
||||
|
||||
impl<K: TotalOrd, V: TotalEq> TotalOrd for BranchElt<K, V> {
|
||||
///Fulfills TotalOrd for BranchElts
|
||||
impl<K: Ord, V: Eq> Ord for BranchElt<K, V> {
|
||||
///Fulfills Ord for BranchElts
|
||||
fn cmp(&self, other: &BranchElt<K, V>) -> Ordering {
|
||||
self.key.cmp(&other.key)
|
||||
}
|
||||
}
|
||||
|
||||
impl<K: fmt::Show + TotalOrd, V: fmt::Show> fmt::Show for BranchElt<K, V> {
|
||||
impl<K: fmt::Show + Ord, V: fmt::Show> fmt::Show for BranchElt<K, V> {
|
||||
/// Returns string containing key, value, and child (which should recur to a
|
||||
/// leaf) Consider changing in future to be more readable.
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
|
@ -388,7 +388,7 @@ impl<T> DList<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: TotalOrd> DList<T> {
|
||||
impl<T: Ord> DList<T> {
|
||||
/// Insert `elt` sorted in ascending order
|
||||
///
|
||||
/// O(N)
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
use std::num::Bitwise;
|
||||
|
||||
#[deriving(Clone, PartialEq, TotalEq, Hash, Show)]
|
||||
#[deriving(Clone, PartialEq, 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
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
use std::container::{Container, Mutable, Map, MutableMap, Set, MutableSet};
|
||||
use std::clone::Clone;
|
||||
use std::cmp::{PartialEq, TotalEq, Equiv, max};
|
||||
use std::cmp::{PartialEq, Eq, Equiv, max};
|
||||
use std::default::Default;
|
||||
use std::fmt;
|
||||
use std::fmt::Show;
|
||||
@ -733,7 +733,7 @@ fn grow_at(capacity: uint, load_factor: Fraction) -> uint {
|
||||
fraction_mul(capacity, load_factor)
|
||||
}
|
||||
|
||||
impl<K: TotalEq + Hash<S>, V, S, H: Hasher<S>> HashMap<K, V, H> {
|
||||
impl<K: Eq + Hash<S>, V, S, H: Hasher<S>> HashMap<K, V, H> {
|
||||
/// Get the number of elements which will force the capacity to shrink.
|
||||
/// When size == self.shrink_at(), we halve the capacity.
|
||||
fn shrink_at(&self) -> uint {
|
||||
@ -925,12 +925,12 @@ impl<K: TotalEq + Hash<S>, V, S, H: Hasher<S>> HashMap<K, V, H> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<K: TotalEq + Hash<S>, V, S, H: Hasher<S>> Container for HashMap<K, V, H> {
|
||||
impl<K: Eq + Hash<S>, V, S, H: Hasher<S>> Container for HashMap<K, V, H> {
|
||||
/// Return the number of elements in the map
|
||||
fn len(&self) -> uint { self.table.size() }
|
||||
}
|
||||
|
||||
impl<K: TotalEq + Hash<S>, V, S, H: Hasher<S>> Mutable for HashMap<K, V, H> {
|
||||
impl<K: Eq + Hash<S>, V, S, H: Hasher<S>> Mutable for HashMap<K, V, H> {
|
||||
/// Clear the map, removing all key-value pairs.
|
||||
fn clear(&mut self) {
|
||||
self.minimum_capacity = self.table.size();
|
||||
@ -945,7 +945,7 @@ impl<K: TotalEq + Hash<S>, V, S, H: Hasher<S>> Mutable for HashMap<K, V, H> {
|
||||
}
|
||||
|
||||
|
||||
impl<K: TotalEq + Hash<S>, V, S, H: Hasher<S>> Map<K, V> for HashMap<K, V, H> {
|
||||
impl<K: Eq + Hash<S>, V, S, H: Hasher<S>> Map<K, V> for HashMap<K, V, H> {
|
||||
fn find<'a>(&'a self, k: &K) -> Option<&'a V> {
|
||||
self.search(k).map(|idx| {
|
||||
let (_, v) = self.table.read(&idx);
|
||||
@ -958,7 +958,7 @@ impl<K: TotalEq + Hash<S>, V, S, H: Hasher<S>> Map<K, V> for HashMap<K, V, H> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<K: TotalEq + Hash<S>, V, S, H: Hasher<S>> MutableMap<K, V> for HashMap<K, V, H> {
|
||||
impl<K: Eq + Hash<S>, V, S, H: Hasher<S>> MutableMap<K, V> for HashMap<K, V, H> {
|
||||
fn find_mut<'a>(&'a mut self, k: &K) -> Option<&'a mut V> {
|
||||
match self.search(k) {
|
||||
None => None,
|
||||
@ -1027,7 +1027,7 @@ impl<K: TotalEq + Hash<S>, V, S, H: Hasher<S>> MutableMap<K, V> for HashMap<K, V
|
||||
|
||||
}
|
||||
|
||||
impl<K: Hash + TotalEq, V> HashMap<K, V, sip::SipHasher> {
|
||||
impl<K: Hash + Eq, V> HashMap<K, V, sip::SipHasher> {
|
||||
/// Create an empty HashMap.
|
||||
pub fn new() -> HashMap<K, V, sip::SipHasher> {
|
||||
HashMap::with_capacity(INITIAL_CAPACITY)
|
||||
@ -1042,7 +1042,7 @@ impl<K: Hash + TotalEq, V> HashMap<K, V, sip::SipHasher> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<K: TotalEq + Hash<S>, V, S, H: Hasher<S>> HashMap<K, V, H> {
|
||||
impl<K: Eq + Hash<S>, V, S, H: Hasher<S>> HashMap<K, V, H> {
|
||||
pub fn with_hasher(hasher: H) -> HashMap<K, V, H> {
|
||||
HashMap::with_capacity_and_hasher(INITIAL_CAPACITY, hasher)
|
||||
}
|
||||
@ -1390,7 +1390,7 @@ impl<K: TotalEq + Hash<S>, V, S, H: Hasher<S>> HashMap<K, V, H> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<K: TotalEq + Hash<S>, V: Clone, S, H: Hasher<S>> HashMap<K, V, H> {
|
||||
impl<K: Eq + Hash<S>, V: Clone, S, H: Hasher<S>> HashMap<K, V, H> {
|
||||
/// Like `find`, but returns a copy of the value.
|
||||
pub fn find_copy(&self, k: &K) -> Option<V> {
|
||||
self.find(k).map(|v| (*v).clone())
|
||||
@ -1402,7 +1402,7 @@ impl<K: TotalEq + Hash<S>, V: Clone, S, H: Hasher<S>> HashMap<K, V, H> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<K: TotalEq + Hash<S>, V: PartialEq, S, H: Hasher<S>> PartialEq for HashMap<K, V, H> {
|
||||
impl<K: Eq + Hash<S>, V: PartialEq, S, H: Hasher<S>> PartialEq for HashMap<K, V, H> {
|
||||
fn eq(&self, other: &HashMap<K, V, H>) -> bool {
|
||||
if self.len() != other.len() { return false; }
|
||||
|
||||
@ -1416,7 +1416,7 @@ impl<K: TotalEq + Hash<S>, V: PartialEq, S, H: Hasher<S>> PartialEq for HashMap<
|
||||
}
|
||||
}
|
||||
|
||||
impl<K: TotalEq + Hash<S> + Show, V: Show, S, H: Hasher<S>> Show for HashMap<K, V, H> {
|
||||
impl<K: Eq + Hash<S> + Show, V: Show, S, H: Hasher<S>> Show for HashMap<K, V, H> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
try!(write!(f, r"\{"));
|
||||
|
||||
@ -1429,7 +1429,7 @@ impl<K: TotalEq + Hash<S> + Show, V: Show, S, H: Hasher<S>> Show for HashMap<K,
|
||||
}
|
||||
}
|
||||
|
||||
impl<K: TotalEq + Hash<S>, V, S, H: Hasher<S> + Default> Default for HashMap<K, V, H> {
|
||||
impl<K: Eq + Hash<S>, V, S, H: Hasher<S> + Default> Default for HashMap<K, V, H> {
|
||||
fn default() -> HashMap<K, V, H> {
|
||||
HashMap::with_hasher(Default::default())
|
||||
}
|
||||
@ -1453,7 +1453,7 @@ pub type Keys<'a, K, V> =
|
||||
pub type Values<'a, K, V> =
|
||||
iter::Map<'static, (&'a K, &'a V), &'a V, Entries<'a, K, V>>;
|
||||
|
||||
impl<K: TotalEq + Hash<S>, V, S, H: Hasher<S> + Default> FromIterator<(K, V)> for HashMap<K, V, H> {
|
||||
impl<K: Eq + Hash<S>, V, S, H: Hasher<S> + Default> FromIterator<(K, V)> for HashMap<K, V, H> {
|
||||
fn from_iter<T: Iterator<(K, V)>>(iter: T) -> HashMap<K, V, H> {
|
||||
let (lower, _) = iter.size_hint();
|
||||
let mut map = HashMap::with_capacity_and_hasher(lower, Default::default());
|
||||
@ -1462,7 +1462,7 @@ impl<K: TotalEq + Hash<S>, V, S, H: Hasher<S> + Default> FromIterator<(K, V)> fo
|
||||
}
|
||||
}
|
||||
|
||||
impl<K: TotalEq + Hash<S>, V, S, H: Hasher<S> + Default> Extendable<(K, V)> for HashMap<K, V, H> {
|
||||
impl<K: Eq + Hash<S>, V, S, H: Hasher<S> + Default> Extendable<(K, V)> for HashMap<K, V, H> {
|
||||
fn extend<T: Iterator<(K, V)>>(&mut self, mut iter: T) {
|
||||
for (k, v) in iter {
|
||||
self.insert(k, v);
|
||||
@ -1486,7 +1486,7 @@ pub struct HashSet<T, H = sip::SipHasher> {
|
||||
map: HashMap<T, (), H>
|
||||
}
|
||||
|
||||
impl<T: TotalEq + Hash<S>, S, H: Hasher<S>> PartialEq for HashSet<T, H> {
|
||||
impl<T: Eq + Hash<S>, S, H: Hasher<S>> PartialEq for HashSet<T, H> {
|
||||
fn eq(&self, other: &HashSet<T, H>) -> bool {
|
||||
if self.len() != other.len() { return false; }
|
||||
|
||||
@ -1494,15 +1494,15 @@ impl<T: TotalEq + Hash<S>, S, H: Hasher<S>> PartialEq for HashSet<T, H> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: TotalEq + Hash<S>, S, H: Hasher<S>> Container for HashSet<T, H> {
|
||||
impl<T: Eq + Hash<S>, S, H: Hasher<S>> Container for HashSet<T, H> {
|
||||
fn len(&self) -> uint { self.map.len() }
|
||||
}
|
||||
|
||||
impl<T: TotalEq + Hash<S>, S, H: Hasher<S>> Mutable for HashSet<T, H> {
|
||||
impl<T: Eq + Hash<S>, S, H: Hasher<S>> Mutable for HashSet<T, H> {
|
||||
fn clear(&mut self) { self.map.clear() }
|
||||
}
|
||||
|
||||
impl<T: TotalEq + Hash<S>, S, H: Hasher<S>> Set<T> for HashSet<T, H> {
|
||||
impl<T: Eq + Hash<S>, S, H: Hasher<S>> Set<T> for HashSet<T, H> {
|
||||
fn contains(&self, value: &T) -> bool { self.map.contains_key(value) }
|
||||
|
||||
fn is_disjoint(&self, other: &HashSet<T, H>) -> bool {
|
||||
@ -1514,13 +1514,13 @@ impl<T: TotalEq + Hash<S>, S, H: Hasher<S>> Set<T> for HashSet<T, H> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: TotalEq + Hash<S>, S, H: Hasher<S>> MutableSet<T> for HashSet<T, H> {
|
||||
impl<T: Eq + Hash<S>, S, H: Hasher<S>> MutableSet<T> for HashSet<T, H> {
|
||||
fn insert(&mut self, value: T) -> bool { self.map.insert(value, ()) }
|
||||
|
||||
fn remove(&mut self, value: &T) -> bool { self.map.remove(value) }
|
||||
}
|
||||
|
||||
impl<T: Hash + TotalEq> HashSet<T, sip::SipHasher> {
|
||||
impl<T: Hash + Eq> HashSet<T, sip::SipHasher> {
|
||||
/// Create an empty HashSet
|
||||
pub fn new() -> HashSet<T, sip::SipHasher> {
|
||||
HashSet::with_capacity(INITIAL_CAPACITY)
|
||||
@ -1533,7 +1533,7 @@ impl<T: Hash + TotalEq> HashSet<T, sip::SipHasher> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: TotalEq + Hash<S>, S, H: Hasher<S>> HashSet<T, H> {
|
||||
impl<T: Eq + Hash<S>, S, H: Hasher<S>> HashSet<T, H> {
|
||||
pub fn with_hasher(hasher: H) -> HashSet<T, H> {
|
||||
HashSet::with_capacity_and_hasher(INITIAL_CAPACITY, hasher)
|
||||
}
|
||||
@ -1603,7 +1603,7 @@ impl<T: TotalEq + Hash<S>, S, H: Hasher<S>> HashSet<T, H> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: TotalEq + Hash<S> + fmt::Show, S, H: Hasher<S>> fmt::Show for HashSet<T, H> {
|
||||
impl<T: Eq + Hash<S> + fmt::Show, S, H: Hasher<S>> fmt::Show for HashSet<T, H> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
try!(write!(f, r"\{"));
|
||||
|
||||
@ -1616,7 +1616,7 @@ impl<T: TotalEq + Hash<S> + fmt::Show, S, H: Hasher<S>> fmt::Show for HashSet<T,
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: TotalEq + Hash<S>, S, H: Hasher<S> + Default> FromIterator<T> for HashSet<T, H> {
|
||||
impl<T: Eq + Hash<S>, S, H: Hasher<S> + Default> FromIterator<T> for HashSet<T, H> {
|
||||
fn from_iter<I: Iterator<T>>(iter: I) -> HashSet<T, H> {
|
||||
let (lower, _) = iter.size_hint();
|
||||
let mut set = HashSet::with_capacity_and_hasher(lower, Default::default());
|
||||
@ -1625,7 +1625,7 @@ impl<T: TotalEq + Hash<S>, S, H: Hasher<S> + Default> FromIterator<T> for HashSe
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: TotalEq + Hash<S>, S, H: Hasher<S> + Default> Extendable<T> for HashSet<T, H> {
|
||||
impl<T: Eq + Hash<S>, S, H: Hasher<S> + Default> Extendable<T> for HashSet<T, H> {
|
||||
fn extend<I: Iterator<T>>(&mut self, mut iter: I) {
|
||||
for k in iter {
|
||||
self.insert(k);
|
||||
@ -1633,7 +1633,7 @@ impl<T: TotalEq + Hash<S>, S, H: Hasher<S> + Default> Extendable<T> for HashSet<
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: TotalEq + Hash> Default for HashSet<T, sip::SipHasher> {
|
||||
impl<T: Eq + Hash> Default for HashSet<T, sip::SipHasher> {
|
||||
fn default() -> HashSet<T> { HashSet::new() }
|
||||
}
|
||||
|
||||
@ -1691,7 +1691,7 @@ mod test_map {
|
||||
|
||||
local_data_key!(drop_vector: RefCell<Vec<int>>)
|
||||
|
||||
#[deriving(Hash, PartialEq, TotalEq)]
|
||||
#[deriving(Hash, PartialEq, Eq)]
|
||||
struct Dropable {
|
||||
k: uint
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ impl<K: PartialEq> PartialEq for KeyRef<K> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<K: TotalEq> TotalEq for KeyRef<K> {}
|
||||
impl<K: Eq> Eq for KeyRef<K> {}
|
||||
|
||||
impl<K, V> LruEntry<K, V> {
|
||||
fn new(k: K, v: V) -> LruEntry<K, V> {
|
||||
@ -86,7 +86,7 @@ impl<K, V> LruEntry<K, V> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<K: Hash + TotalEq, V> LruCache<K, V> {
|
||||
impl<K: Hash + Eq, V> LruCache<K, V> {
|
||||
/// Create an LRU Cache that holds at most `capacity` items.
|
||||
pub fn new(capacity: uint) -> LruCache<K, V> {
|
||||
let cache = LruCache {
|
||||
@ -201,7 +201,7 @@ impl<K: Hash + TotalEq, V> LruCache<K, V> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<A: fmt::Show + Hash + TotalEq, B: fmt::Show> fmt::Show for LruCache<A, B> {
|
||||
impl<A: fmt::Show + Hash + Eq, B: fmt::Show> fmt::Show for LruCache<A, B> {
|
||||
/// Return a string that lists the key-value pairs from most-recently
|
||||
/// used to least-recently used.
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
@ -222,14 +222,14 @@ impl<A: fmt::Show + Hash + TotalEq, B: fmt::Show> fmt::Show for LruCache<A, B> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<K: Hash + TotalEq, V> Container for LruCache<K, V> {
|
||||
impl<K: Hash + Eq, V> Container for LruCache<K, V> {
|
||||
/// Return the number of key-value pairs in the cache.
|
||||
fn len(&self) -> uint {
|
||||
self.map.len()
|
||||
}
|
||||
}
|
||||
|
||||
impl<K: Hash + TotalEq, V> Mutable for LruCache<K, V> {
|
||||
impl<K: Hash + Eq, V> Mutable for LruCache<K, V> {
|
||||
/// Clear the cache of all key-value pairs.
|
||||
fn clear(&mut self) {
|
||||
self.map.clear();
|
||||
|
@ -22,17 +22,17 @@ pub struct PriorityQueue<T> {
|
||||
data: Vec<T>,
|
||||
}
|
||||
|
||||
impl<T: TotalOrd> Container for PriorityQueue<T> {
|
||||
impl<T: Ord> Container for PriorityQueue<T> {
|
||||
/// Returns the length of the queue
|
||||
fn len(&self) -> uint { self.data.len() }
|
||||
}
|
||||
|
||||
impl<T: TotalOrd> Mutable for PriorityQueue<T> {
|
||||
impl<T: Ord> Mutable for PriorityQueue<T> {
|
||||
/// Drop all items from the queue
|
||||
fn clear(&mut self) { self.data.truncate(0) }
|
||||
}
|
||||
|
||||
impl<T: TotalOrd> PriorityQueue<T> {
|
||||
impl<T: Ord> PriorityQueue<T> {
|
||||
/// An iterator visiting all values in underlying vector, in
|
||||
/// arbitrary order.
|
||||
pub fn iter<'a>(&'a self) -> Items<'a, T> {
|
||||
@ -214,7 +214,7 @@ impl<'a, T> Iterator<&'a T> for Items<'a, T> {
|
||||
fn size_hint(&self) -> (uint, Option<uint>) { self.iter.size_hint() }
|
||||
}
|
||||
|
||||
impl<T: TotalOrd> FromIterator<T> for PriorityQueue<T> {
|
||||
impl<T: Ord> FromIterator<T> for PriorityQueue<T> {
|
||||
fn from_iter<Iter: Iterator<T>>(iter: Iter) -> PriorityQueue<T> {
|
||||
let mut q = PriorityQueue::new();
|
||||
q.extend(iter);
|
||||
@ -222,7 +222,7 @@ impl<T: TotalOrd> FromIterator<T> for PriorityQueue<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: TotalOrd> Extendable<T> for PriorityQueue<T> {
|
||||
impl<T: Ord> Extendable<T> for PriorityQueue<T> {
|
||||
fn extend<Iter: Iterator<T>>(&mut self, mut iter: Iter) {
|
||||
let (lower, _) = iter.size_hint();
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
//! An ordered map and set implemented as self-balancing binary search
|
||||
//! trees. The only requirement for the types is that the key implements
|
||||
//! `TotalOrd`.
|
||||
//! `Ord`.
|
||||
|
||||
use std::cmp::Ordering;
|
||||
use std::fmt::Show;
|
||||
@ -43,7 +43,7 @@ pub struct TreeMap<K, V> {
|
||||
length: uint
|
||||
}
|
||||
|
||||
impl<K: PartialEq + TotalOrd, V: PartialEq> PartialEq for TreeMap<K, V> {
|
||||
impl<K: PartialEq + Ord, V: PartialEq> PartialEq for TreeMap<K, V> {
|
||||
fn eq(&self, other: &TreeMap<K, V>) -> bool {
|
||||
self.len() == other.len() &&
|
||||
self.iter().zip(other.iter()).all(|(a, b)| a == b)
|
||||
@ -51,7 +51,7 @@ impl<K: PartialEq + TotalOrd, V: PartialEq> PartialEq for TreeMap<K, V> {
|
||||
}
|
||||
|
||||
// Lexicographical comparison
|
||||
fn lt<K: PartialOrd + TotalOrd, V: PartialOrd>(a: &TreeMap<K, V>,
|
||||
fn lt<K: PartialOrd + Ord, V: PartialOrd>(a: &TreeMap<K, V>,
|
||||
b: &TreeMap<K, V>) -> bool {
|
||||
// the Zip iterator is as long as the shortest of a and b.
|
||||
for ((key_a, value_a), (key_b, value_b)) in a.iter().zip(b.iter()) {
|
||||
@ -64,12 +64,12 @@ fn lt<K: PartialOrd + TotalOrd, V: PartialOrd>(a: &TreeMap<K, V>,
|
||||
a.len() < b.len()
|
||||
}
|
||||
|
||||
impl<K: PartialOrd + TotalOrd, V: PartialOrd> PartialOrd for TreeMap<K, V> {
|
||||
impl<K: PartialOrd + Ord, V: PartialOrd> PartialOrd for TreeMap<K, V> {
|
||||
#[inline]
|
||||
fn lt(&self, other: &TreeMap<K, V>) -> bool { lt(self, other) }
|
||||
}
|
||||
|
||||
impl<K: TotalOrd + Show, V: Show> Show for TreeMap<K, V> {
|
||||
impl<K: Ord + Show, V: Show> Show for TreeMap<K, V> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
try!(write!(f, r"\{"));
|
||||
|
||||
@ -82,18 +82,18 @@ impl<K: TotalOrd + Show, V: Show> Show for TreeMap<K, V> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<K: TotalOrd, V> Container for TreeMap<K, V> {
|
||||
impl<K: Ord, V> Container for TreeMap<K, V> {
|
||||
fn len(&self) -> uint { self.length }
|
||||
}
|
||||
|
||||
impl<K: TotalOrd, V> Mutable for TreeMap<K, V> {
|
||||
impl<K: Ord, V> Mutable for TreeMap<K, V> {
|
||||
fn clear(&mut self) {
|
||||
self.root = None;
|
||||
self.length = 0
|
||||
}
|
||||
}
|
||||
|
||||
impl<K: TotalOrd, V> Map<K, V> for TreeMap<K, V> {
|
||||
impl<K: Ord, V> Map<K, V> for TreeMap<K, V> {
|
||||
fn find<'a>(&'a self, key: &K) -> Option<&'a V> {
|
||||
let mut current: &'a Option<Box<TreeNode<K, V>>> = &self.root;
|
||||
loop {
|
||||
@ -111,7 +111,7 @@ impl<K: TotalOrd, V> Map<K, V> for TreeMap<K, V> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<K: TotalOrd, V> MutableMap<K, V> for TreeMap<K, V> {
|
||||
impl<K: Ord, V> MutableMap<K, V> for TreeMap<K, V> {
|
||||
#[inline]
|
||||
fn find_mut<'a>(&'a mut self, key: &K) -> Option<&'a mut V> {
|
||||
find_mut(&mut self.root, key)
|
||||
@ -130,7 +130,7 @@ impl<K: TotalOrd, V> MutableMap<K, V> for TreeMap<K, V> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<K: TotalOrd, V> TreeMap<K, V> {
|
||||
impl<K: Ord, V> TreeMap<K, V> {
|
||||
/// Create an empty TreeMap
|
||||
pub fn new() -> TreeMap<K, V> { TreeMap{root: None, length: 0} }
|
||||
|
||||
@ -216,7 +216,7 @@ macro_rules! bound_setup {
|
||||
}
|
||||
|
||||
|
||||
impl<K: TotalOrd, V> TreeMap<K, V> {
|
||||
impl<K: Ord, V> TreeMap<K, V> {
|
||||
/// Get a lazy iterator that should be initialized using
|
||||
/// `traverse_left`/`traverse_right`/`traverse_complete`.
|
||||
fn iter_for_traversal<'a>(&'a self) -> Entries<'a, K, V> {
|
||||
@ -546,23 +546,23 @@ impl<'a, T> Iterator<&'a T> for RevSetItems<'a, T> {
|
||||
|
||||
/// A implementation of the `Set` trait on top of the `TreeMap` container. The
|
||||
/// only requirement is that the type of the elements contained ascribes to the
|
||||
/// `TotalOrd` trait.
|
||||
/// `Ord` trait.
|
||||
#[deriving(Clone)]
|
||||
pub struct TreeSet<T> {
|
||||
map: TreeMap<T, ()>
|
||||
}
|
||||
|
||||
impl<T: PartialEq + TotalOrd> PartialEq for TreeSet<T> {
|
||||
impl<T: PartialEq + Ord> PartialEq for TreeSet<T> {
|
||||
#[inline]
|
||||
fn eq(&self, other: &TreeSet<T>) -> bool { self.map == other.map }
|
||||
}
|
||||
|
||||
impl<T: PartialOrd + TotalOrd> PartialOrd for TreeSet<T> {
|
||||
impl<T: PartialOrd + Ord> PartialOrd for TreeSet<T> {
|
||||
#[inline]
|
||||
fn lt(&self, other: &TreeSet<T>) -> bool { self.map < other.map }
|
||||
}
|
||||
|
||||
impl<T: TotalOrd + Show> Show for TreeSet<T> {
|
||||
impl<T: Ord + Show> Show for TreeSet<T> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
try!(write!(f, r"\{"));
|
||||
|
||||
@ -575,17 +575,17 @@ impl<T: TotalOrd + Show> Show for TreeSet<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: TotalOrd> Container for TreeSet<T> {
|
||||
impl<T: Ord> Container for TreeSet<T> {
|
||||
#[inline]
|
||||
fn len(&self) -> uint { self.map.len() }
|
||||
}
|
||||
|
||||
impl<T: TotalOrd> Mutable for TreeSet<T> {
|
||||
impl<T: Ord> Mutable for TreeSet<T> {
|
||||
#[inline]
|
||||
fn clear(&mut self) { self.map.clear() }
|
||||
}
|
||||
|
||||
impl<T: TotalOrd> Set<T> for TreeSet<T> {
|
||||
impl<T: Ord> Set<T> for TreeSet<T> {
|
||||
#[inline]
|
||||
fn contains(&self, value: &T) -> bool {
|
||||
self.map.contains_key(value)
|
||||
@ -620,7 +620,7 @@ impl<T: TotalOrd> Set<T> for TreeSet<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: TotalOrd> MutableSet<T> for TreeSet<T> {
|
||||
impl<T: Ord> MutableSet<T> for TreeSet<T> {
|
||||
#[inline]
|
||||
fn insert(&mut self, value: T) -> bool { self.map.insert(value, ()) }
|
||||
|
||||
@ -628,7 +628,7 @@ impl<T: TotalOrd> MutableSet<T> for TreeSet<T> {
|
||||
fn remove(&mut self, value: &T) -> bool { self.map.remove(value) }
|
||||
}
|
||||
|
||||
impl<T: TotalOrd> TreeSet<T> {
|
||||
impl<T: Ord> TreeSet<T> {
|
||||
/// Create an empty TreeSet
|
||||
#[inline]
|
||||
pub fn new() -> TreeSet<T> { TreeSet{map: TreeMap::new()} }
|
||||
@ -728,7 +728,7 @@ pub struct UnionItems<'a, T> {
|
||||
}
|
||||
|
||||
/// Compare `x` and `y`, but return `short` if x is None and `long` if y is None
|
||||
fn cmp_opt<T: TotalOrd>(x: Option<&T>, y: Option<&T>,
|
||||
fn cmp_opt<T: Ord>(x: Option<&T>, y: Option<&T>,
|
||||
short: Ordering, long: Ordering) -> Ordering {
|
||||
match (x, y) {
|
||||
(None , _ ) => short,
|
||||
@ -737,7 +737,7 @@ fn cmp_opt<T: TotalOrd>(x: Option<&T>, y: Option<&T>,
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T: TotalOrd> Iterator<&'a T> for DifferenceItems<'a, T> {
|
||||
impl<'a, T: Ord> Iterator<&'a T> for DifferenceItems<'a, T> {
|
||||
fn next(&mut self) -> Option<&'a T> {
|
||||
loop {
|
||||
match cmp_opt(self.a.peek(), self.b.peek(), Less, Less) {
|
||||
@ -749,7 +749,7 @@ impl<'a, T: TotalOrd> Iterator<&'a T> for DifferenceItems<'a, T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T: TotalOrd> Iterator<&'a T> for SymDifferenceItems<'a, T> {
|
||||
impl<'a, T: Ord> Iterator<&'a T> for SymDifferenceItems<'a, T> {
|
||||
fn next(&mut self) -> Option<&'a T> {
|
||||
loop {
|
||||
match cmp_opt(self.a.peek(), self.b.peek(), Greater, Less) {
|
||||
@ -761,7 +761,7 @@ impl<'a, T: TotalOrd> Iterator<&'a T> for SymDifferenceItems<'a, T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T: TotalOrd> Iterator<&'a T> for IntersectionItems<'a, T> {
|
||||
impl<'a, T: Ord> Iterator<&'a T> for IntersectionItems<'a, T> {
|
||||
fn next(&mut self) -> Option<&'a T> {
|
||||
loop {
|
||||
let o_cmp = match (self.a.peek(), self.b.peek()) {
|
||||
@ -779,7 +779,7 @@ impl<'a, T: TotalOrd> Iterator<&'a T> for IntersectionItems<'a, T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T: TotalOrd> Iterator<&'a T> for UnionItems<'a, T> {
|
||||
impl<'a, T: Ord> Iterator<&'a T> for UnionItems<'a, T> {
|
||||
fn next(&mut self) -> Option<&'a T> {
|
||||
loop {
|
||||
match cmp_opt(self.a.peek(), self.b.peek(), Greater, Less) {
|
||||
@ -803,7 +803,7 @@ struct TreeNode<K, V> {
|
||||
level: uint
|
||||
}
|
||||
|
||||
impl<K: TotalOrd, V> TreeNode<K, V> {
|
||||
impl<K: Ord, V> TreeNode<K, V> {
|
||||
/// Creates a new tree node.
|
||||
#[inline]
|
||||
pub fn new(key: K, value: V) -> TreeNode<K, V> {
|
||||
@ -812,7 +812,7 @@ impl<K: TotalOrd, V> TreeNode<K, V> {
|
||||
}
|
||||
|
||||
// Remove left horizontal link by rotating right
|
||||
fn skew<K: TotalOrd, V>(node: &mut Box<TreeNode<K, V>>) {
|
||||
fn skew<K: Ord, V>(node: &mut Box<TreeNode<K, V>>) {
|
||||
if node.left.as_ref().map_or(false, |x| x.level == node.level) {
|
||||
let mut save = node.left.take_unwrap();
|
||||
swap(&mut node.left, &mut save.right); // save.right now None
|
||||
@ -823,7 +823,7 @@ fn skew<K: TotalOrd, V>(node: &mut Box<TreeNode<K, V>>) {
|
||||
|
||||
// Remove dual horizontal link by rotating left and increasing level of
|
||||
// the parent
|
||||
fn split<K: TotalOrd, V>(node: &mut Box<TreeNode<K, V>>) {
|
||||
fn split<K: Ord, V>(node: &mut Box<TreeNode<K, V>>) {
|
||||
if node.right.as_ref().map_or(false,
|
||||
|x| x.right.as_ref().map_or(false, |y| y.level == node.level)) {
|
||||
let mut save = node.right.take_unwrap();
|
||||
@ -834,7 +834,7 @@ fn split<K: TotalOrd, V>(node: &mut Box<TreeNode<K, V>>) {
|
||||
}
|
||||
}
|
||||
|
||||
fn find_mut<'r, K: TotalOrd, V>(node: &'r mut Option<Box<TreeNode<K, V>>>,
|
||||
fn find_mut<'r, K: Ord, V>(node: &'r mut Option<Box<TreeNode<K, V>>>,
|
||||
key: &K)
|
||||
-> Option<&'r mut V> {
|
||||
match *node {
|
||||
@ -849,7 +849,7 @@ fn find_mut<'r, K: TotalOrd, V>(node: &'r mut Option<Box<TreeNode<K, V>>>,
|
||||
}
|
||||
}
|
||||
|
||||
fn insert<K: TotalOrd, V>(node: &mut Option<Box<TreeNode<K, V>>>,
|
||||
fn insert<K: Ord, V>(node: &mut Option<Box<TreeNode<K, V>>>,
|
||||
key: K, value: V) -> Option<V> {
|
||||
match *node {
|
||||
Some(ref mut save) => {
|
||||
@ -879,9 +879,9 @@ fn insert<K: TotalOrd, V>(node: &mut Option<Box<TreeNode<K, V>>>,
|
||||
}
|
||||
}
|
||||
|
||||
fn remove<K: TotalOrd, V>(node: &mut Option<Box<TreeNode<K, V>>>,
|
||||
fn remove<K: Ord, V>(node: &mut Option<Box<TreeNode<K, V>>>,
|
||||
key: &K) -> Option<V> {
|
||||
fn heir_swap<K: TotalOrd, V>(node: &mut Box<TreeNode<K, V>>,
|
||||
fn heir_swap<K: Ord, V>(node: &mut Box<TreeNode<K, V>>,
|
||||
child: &mut Option<Box<TreeNode<K, V>>>) {
|
||||
// *could* be done without recursion, but it won't borrow check
|
||||
for x in child.mut_iter() {
|
||||
@ -962,7 +962,7 @@ fn remove<K: TotalOrd, V>(node: &mut Option<Box<TreeNode<K, V>>>,
|
||||
};
|
||||
}
|
||||
|
||||
impl<K: TotalOrd, V> FromIterator<(K, V)> for TreeMap<K, V> {
|
||||
impl<K: Ord, V> FromIterator<(K, V)> for TreeMap<K, V> {
|
||||
fn from_iter<T: Iterator<(K, V)>>(iter: T) -> TreeMap<K, V> {
|
||||
let mut map = TreeMap::new();
|
||||
map.extend(iter);
|
||||
@ -970,7 +970,7 @@ impl<K: TotalOrd, V> FromIterator<(K, V)> for TreeMap<K, V> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<K: TotalOrd, V> Extendable<(K, V)> for TreeMap<K, V> {
|
||||
impl<K: Ord, V> Extendable<(K, V)> for TreeMap<K, V> {
|
||||
#[inline]
|
||||
fn extend<T: Iterator<(K, V)>>(&mut self, mut iter: T) {
|
||||
for (k, v) in iter {
|
||||
@ -979,7 +979,7 @@ impl<K: TotalOrd, V> Extendable<(K, V)> for TreeMap<K, V> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: TotalOrd> FromIterator<T> for TreeSet<T> {
|
||||
impl<T: Ord> FromIterator<T> for TreeSet<T> {
|
||||
fn from_iter<Iter: Iterator<T>>(iter: Iter) -> TreeSet<T> {
|
||||
let mut set = TreeSet::new();
|
||||
set.extend(iter);
|
||||
@ -987,7 +987,7 @@ impl<T: TotalOrd> FromIterator<T> for TreeSet<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: TotalOrd> Extendable<T> for TreeSet<T> {
|
||||
impl<T: Ord> Extendable<T> for TreeSet<T> {
|
||||
#[inline]
|
||||
fn extend<Iter: Iterator<T>>(&mut self, mut iter: Iter) {
|
||||
for elem in iter {
|
||||
@ -1070,7 +1070,7 @@ mod test_treemap {
|
||||
assert_eq!(m.find(&k1), Some(&v1));
|
||||
}
|
||||
|
||||
fn check_equal<K: PartialEq + TotalOrd, V: PartialEq>(ctrl: &[(K, V)],
|
||||
fn check_equal<K: PartialEq + Ord, V: PartialEq>(ctrl: &[(K, V)],
|
||||
map: &TreeMap<K, V>) {
|
||||
assert_eq!(ctrl.is_empty(), map.is_empty());
|
||||
for x in ctrl.iter() {
|
||||
@ -1091,7 +1091,7 @@ mod test_treemap {
|
||||
}
|
||||
}
|
||||
|
||||
fn check_left<K: TotalOrd, V>(node: &Option<Box<TreeNode<K, V>>>,
|
||||
fn check_left<K: Ord, V>(node: &Option<Box<TreeNode<K, V>>>,
|
||||
parent: &Box<TreeNode<K, V>>) {
|
||||
match *node {
|
||||
Some(ref r) => {
|
||||
@ -1104,7 +1104,7 @@ mod test_treemap {
|
||||
}
|
||||
}
|
||||
|
||||
fn check_right<K: TotalOrd, V>(node: &Option<Box<TreeNode<K, V>>>,
|
||||
fn check_right<K: Ord, V>(node: &Option<Box<TreeNode<K, V>>>,
|
||||
parent: &Box<TreeNode<K, V>>,
|
||||
parent_red: bool) {
|
||||
match *node {
|
||||
@ -1121,7 +1121,7 @@ mod test_treemap {
|
||||
}
|
||||
}
|
||||
|
||||
fn check_structure<K: TotalOrd, V>(map: &TreeMap<K, V>) {
|
||||
fn check_structure<K: Ord, V>(map: &TreeMap<K, V>) {
|
||||
match map.root {
|
||||
Some(ref r) => {
|
||||
check_left(&r.left, r);
|
||||
|
@ -37,9 +37,6 @@
|
||||
//! assert!(SketchyNum {num: 25} != SketchyNum {num: 57});
|
||||
//! ```
|
||||
|
||||
pub use Eq = self::TotalEq;
|
||||
pub use Ord = self::TotalOrd;
|
||||
|
||||
/// Trait for values that can be compared for equality and inequality.
|
||||
///
|
||||
/// This trait allows partial equality, where types can be unordered instead of
|
||||
@ -51,7 +48,7 @@ pub use Ord = self::TotalOrd;
|
||||
/// default.
|
||||
///
|
||||
/// Eventually, this will be implemented by default for types that implement
|
||||
/// `TotalEq`.
|
||||
/// `Eq`.
|
||||
#[lang="eq"]
|
||||
pub trait PartialEq {
|
||||
/// This method tests for `self` and `other` values to be equal, and is used by `==`.
|
||||
@ -71,7 +68,7 @@ pub trait PartialEq {
|
||||
/// - reflexive: `a == a`;
|
||||
/// - symmetric: `a == b` implies `b == a`; and
|
||||
/// - transitive: `a == b` and `b == c` implies `a == c`.
|
||||
pub trait TotalEq: PartialEq {
|
||||
pub trait Eq: PartialEq {
|
||||
// FIXME #13101: this method is used solely by #[deriving] to
|
||||
// assert that every component of a type implements #[deriving]
|
||||
// itself, the current deriving infrastructure means doing this
|
||||
@ -104,7 +101,7 @@ pub enum Ordering {
|
||||
/// true; and
|
||||
/// - transitive, `a < b` and `b < c` implies `a < c`. The same must hold for
|
||||
/// both `==` and `>`.
|
||||
pub trait TotalOrd: TotalEq + PartialOrd {
|
||||
pub trait Ord: Eq + PartialOrd {
|
||||
/// This method returns an ordering between `self` and `other` values.
|
||||
///
|
||||
/// By convention, `self.cmp(&other)` returns the ordering matching
|
||||
@ -118,9 +115,9 @@ pub trait TotalOrd: TotalEq + PartialOrd {
|
||||
fn cmp(&self, other: &Self) -> Ordering;
|
||||
}
|
||||
|
||||
impl TotalEq for Ordering {}
|
||||
impl Eq for Ordering {}
|
||||
|
||||
impl TotalOrd for Ordering {
|
||||
impl Ord for Ordering {
|
||||
#[inline]
|
||||
fn cmp(&self, other: &Ordering) -> Ordering {
|
||||
(*self as int).cmp(&(*other as int))
|
||||
@ -182,20 +179,20 @@ pub trait Equiv<T> {
|
||||
|
||||
/// Compare and return the minimum of two values.
|
||||
#[inline]
|
||||
pub fn min<T: TotalOrd>(v1: T, v2: T) -> T {
|
||||
pub fn min<T: Ord>(v1: T, v2: T) -> T {
|
||||
if v1 < v2 { v1 } else { v2 }
|
||||
}
|
||||
|
||||
/// Compare and return the maximum of two values.
|
||||
#[inline]
|
||||
pub fn max<T: TotalOrd>(v1: T, v2: T) -> T {
|
||||
pub fn max<T: Ord>(v1: T, v2: T) -> T {
|
||||
if v1 > v2 { v1 } else { v2 }
|
||||
}
|
||||
|
||||
// Implementation of PartialEq, TotalEq, PartialOrd and TotalOrd for primitive types
|
||||
// Implementation of PartialEq, Eq, PartialOrd and Ord for primitive types
|
||||
#[cfg(not(test))]
|
||||
mod impls {
|
||||
use cmp::{PartialOrd, TotalOrd, PartialEq, TotalEq, Ordering,
|
||||
use cmp::{PartialOrd, Ord, PartialEq, Eq, Ordering,
|
||||
Less, Greater, Equal};
|
||||
|
||||
macro_rules! eq_impl(
|
||||
@ -220,7 +217,7 @@ mod impls {
|
||||
|
||||
macro_rules! totaleq_impl(
|
||||
($($t:ty)*) => ($(
|
||||
impl TotalEq for $t {}
|
||||
impl Eq for $t {}
|
||||
)*)
|
||||
)
|
||||
|
||||
@ -257,7 +254,7 @@ mod impls {
|
||||
|
||||
macro_rules! totalord_impl(
|
||||
($($t:ty)*) => ($(
|
||||
impl TotalOrd for $t {
|
||||
impl Ord for $t {
|
||||
#[inline]
|
||||
fn cmp(&self, other: &$t) -> Ordering {
|
||||
if *self < *other { Less }
|
||||
@ -268,12 +265,12 @@ mod impls {
|
||||
)*)
|
||||
)
|
||||
|
||||
impl TotalOrd for () {
|
||||
impl Ord for () {
|
||||
#[inline]
|
||||
fn cmp(&self, _other: &()) -> Ordering { Equal }
|
||||
}
|
||||
|
||||
impl TotalOrd for bool {
|
||||
impl Ord for bool {
|
||||
#[inline]
|
||||
fn cmp(&self, other: &bool) -> Ordering {
|
||||
(*self as u8).cmp(&(*other as u8))
|
||||
@ -299,11 +296,11 @@ mod impls {
|
||||
#[inline]
|
||||
fn gt(&self, other: & &'a T) -> bool { *(*self) > *(*other) }
|
||||
}
|
||||
impl<'a, T: TotalOrd> TotalOrd for &'a T {
|
||||
impl<'a, T: Ord> Ord for &'a T {
|
||||
#[inline]
|
||||
fn cmp(&self, other: & &'a T) -> Ordering { (**self).cmp(*other) }
|
||||
}
|
||||
impl<'a, T: TotalEq> TotalEq for &'a T {}
|
||||
impl<'a, T: Eq> Eq for &'a T {}
|
||||
|
||||
// &mut pointers
|
||||
impl<'a, T: PartialEq> PartialEq for &'a mut T {
|
||||
@ -322,11 +319,11 @@ mod impls {
|
||||
#[inline]
|
||||
fn gt(&self, other: &&'a mut T) -> bool { **self > **other }
|
||||
}
|
||||
impl<'a, T: TotalOrd> TotalOrd for &'a mut T {
|
||||
impl<'a, T: Ord> Ord for &'a mut T {
|
||||
#[inline]
|
||||
fn cmp(&self, other: &&'a mut T) -> Ordering { (**self).cmp(*other) }
|
||||
}
|
||||
impl<'a, T: TotalEq> TotalEq for &'a mut T {}
|
||||
impl<'a, T: Eq> Eq for &'a mut T {}
|
||||
|
||||
// @ pointers
|
||||
impl<T:PartialEq> PartialEq for @T {
|
||||
@ -345,11 +342,11 @@ mod impls {
|
||||
#[inline]
|
||||
fn gt(&self, other: &@T) -> bool { *(*self) > *(*other) }
|
||||
}
|
||||
impl<T: TotalOrd> TotalOrd for @T {
|
||||
impl<T: Ord> Ord for @T {
|
||||
#[inline]
|
||||
fn cmp(&self, other: &@T) -> Ordering { (**self).cmp(*other) }
|
||||
}
|
||||
impl<T: TotalEq> TotalEq for @T {}
|
||||
impl<T: Eq> Eq for @T {}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
@ -550,7 +550,7 @@ extern "rust-intrinsic" {
|
||||
/// `TypeId` represents a globally unique identifier for a type
|
||||
#[lang="type_id"] // This needs to be kept in lockstep with the code in trans/intrinsic.rs and
|
||||
// middle/lang_items.rs
|
||||
#[deriving(PartialEq, TotalEq, Show)]
|
||||
#[deriving(PartialEq, Eq, Show)]
|
||||
#[cfg(not(test))]
|
||||
pub struct TypeId {
|
||||
t: u64,
|
||||
|
@ -68,7 +68,7 @@ use cmp;
|
||||
use num::{Zero, One, CheckedAdd, CheckedSub, Saturating, ToPrimitive, Int};
|
||||
use option::{Option, Some, None};
|
||||
use ops::{Add, Mul, Sub};
|
||||
use cmp::{PartialEq, PartialOrd, TotalOrd};
|
||||
use cmp::{PartialEq, PartialOrd, Ord};
|
||||
use clone::Clone;
|
||||
use uint;
|
||||
use mem;
|
||||
@ -611,7 +611,7 @@ pub trait Iterator<A> {
|
||||
/// assert_eq!(*xs.iter().max_by(|x| x.abs()).unwrap(), -10);
|
||||
/// ```
|
||||
#[inline]
|
||||
fn max_by<B: TotalOrd>(&mut self, f: |&A| -> B) -> Option<A> {
|
||||
fn max_by<B: Ord>(&mut self, f: |&A| -> B) -> Option<A> {
|
||||
self.fold(None, |max: Option<(A, B)>, x| {
|
||||
let x_val = f(&x);
|
||||
match max {
|
||||
@ -635,7 +635,7 @@ pub trait Iterator<A> {
|
||||
/// assert_eq!(*xs.iter().min_by(|x| x.abs()).unwrap(), 0);
|
||||
/// ```
|
||||
#[inline]
|
||||
fn min_by<B: TotalOrd>(&mut self, f: |&A| -> B) -> Option<A> {
|
||||
fn min_by<B: Ord>(&mut self, f: |&A| -> B) -> Option<A> {
|
||||
self.fold(None, |min: Option<(A, B)>, x| {
|
||||
let x_val = f(&x);
|
||||
match min {
|
||||
@ -905,7 +905,7 @@ pub trait OrdIterator<A> {
|
||||
fn min_max(&mut self) -> MinMaxResult<A>;
|
||||
}
|
||||
|
||||
impl<A: TotalOrd, T: Iterator<A>> OrdIterator<A> for T {
|
||||
impl<A: Ord, T: Iterator<A>> OrdIterator<A> for T {
|
||||
#[inline]
|
||||
fn max(&mut self) -> Option<A> {
|
||||
self.fold(None, |max, x| {
|
||||
@ -2182,12 +2182,12 @@ impl<A: Clone> RandomAccessIterator<A> for Repeat<A> {
|
||||
/// the shorter sequence compares less.
|
||||
pub mod order {
|
||||
use cmp;
|
||||
use cmp::{TotalEq, TotalOrd, PartialOrd, PartialEq};
|
||||
use cmp::{Eq, Ord, PartialOrd, PartialEq};
|
||||
use option::{Some, None};
|
||||
use super::Iterator;
|
||||
|
||||
/// Compare `a` and `b` for equality using `TotalEq`
|
||||
pub fn equals<A: TotalEq, T: Iterator<A>, S: Iterator<A>>(mut a: T, mut b: S) -> bool {
|
||||
/// Compare `a` and `b` for equality using `Eq`
|
||||
pub fn equals<A: Eq, T: Iterator<A>, S: Iterator<A>>(mut a: T, mut b: S) -> bool {
|
||||
loop {
|
||||
match (a.next(), b.next()) {
|
||||
(None, None) => return true,
|
||||
@ -2197,8 +2197,8 @@ pub mod order {
|
||||
}
|
||||
}
|
||||
|
||||
/// Order `a` and `b` lexicographically using `TotalOrd`
|
||||
pub fn cmp<A: TotalOrd, T: Iterator<A>, S: Iterator<A>>(mut a: T, mut b: S) -> cmp::Ordering {
|
||||
/// Order `a` and `b` lexicographically using `Ord`
|
||||
pub fn cmp<A: Ord, T: Iterator<A>, S: Iterator<A>>(mut a: T, mut b: S) -> cmp::Ordering {
|
||||
loop {
|
||||
match (a.next(), b.next()) {
|
||||
(None, None) => return cmp::Equal,
|
||||
|
@ -141,14 +141,14 @@
|
||||
//! }
|
||||
//! ```
|
||||
|
||||
use cmp::{PartialEq, TotalEq, TotalOrd};
|
||||
use cmp::{PartialEq, Eq, Ord};
|
||||
use default::Default;
|
||||
use iter::{Iterator, DoubleEndedIterator, FromIterator, ExactSize};
|
||||
use mem;
|
||||
use slice;
|
||||
|
||||
/// The `Option`
|
||||
#[deriving(Clone, PartialEq, PartialOrd, TotalEq, TotalOrd, Show)]
|
||||
#[deriving(Clone, PartialEq, PartialOrd, Eq, Ord, Show)]
|
||||
pub enum Option<T> {
|
||||
/// No value
|
||||
None,
|
||||
|
@ -45,7 +45,7 @@ pub use mem::drop;
|
||||
|
||||
pub use char::Char;
|
||||
pub use clone::Clone;
|
||||
pub use cmp::{PartialEq, PartialOrd, TotalEq, TotalOrd};
|
||||
pub use cmp::{PartialEq, PartialOrd, Eq, Ord};
|
||||
pub use cmp::{Ordering, Less, Equal, Greater, Equiv};
|
||||
pub use container::{Container, Mutable, Map, MutableMap, Set, MutableSet};
|
||||
pub use iter::{FromIterator, Extendable};
|
||||
@ -59,6 +59,6 @@ pub use str::{Str, StrSlice};
|
||||
pub use tuple::{Tuple1, Tuple2, Tuple3, Tuple4};
|
||||
pub use tuple::{Tuple5, Tuple6, Tuple7, Tuple8};
|
||||
pub use tuple::{Tuple9, Tuple10, Tuple11, Tuple12};
|
||||
pub use slice::{ImmutableEqVector, ImmutableTotalOrdVector};
|
||||
pub use slice::{ImmutableEqVector, ImmutableOrdVector};
|
||||
pub use slice::{MutableVector};
|
||||
pub use slice::{Vector, ImmutableVector};
|
||||
|
@ -93,7 +93,7 @@ use intrinsics;
|
||||
use iter::{range, Iterator};
|
||||
use option::{Some, None, Option};
|
||||
|
||||
#[cfg(not(test))] use cmp::{PartialEq, TotalEq, PartialOrd, Equiv};
|
||||
#[cfg(not(test))] use cmp::{PartialEq, Eq, PartialOrd, Equiv};
|
||||
|
||||
/// Return the offset of the first null pointer in `buf`.
|
||||
#[inline]
|
||||
@ -396,7 +396,7 @@ impl<T> PartialEq for *T {
|
||||
}
|
||||
|
||||
#[cfg(not(test))]
|
||||
impl<T> TotalEq for *T {}
|
||||
impl<T> Eq for *T {}
|
||||
|
||||
#[cfg(not(test))]
|
||||
impl<T> PartialEq for *mut T {
|
||||
@ -409,7 +409,7 @@ impl<T> PartialEq for *mut T {
|
||||
}
|
||||
|
||||
#[cfg(not(test))]
|
||||
impl<T> TotalEq for *mut T {}
|
||||
impl<T> Eq for *mut T {}
|
||||
|
||||
// Equivalence for pointers
|
||||
#[cfg(not(test))]
|
||||
|
@ -283,7 +283,7 @@ use option::{None, Option, Some};
|
||||
/// `Result` is a type that represents either success (`Ok`) or failure (`Err`).
|
||||
///
|
||||
/// See the [`std::result`](index.html) module documentation for details.
|
||||
#[deriving(Clone, PartialEq, PartialOrd, TotalEq, TotalOrd, Show)]
|
||||
#[deriving(Clone, PartialEq, PartialOrd, Eq, Ord, Show)]
|
||||
#[must_use]
|
||||
pub enum Result<T, E> {
|
||||
/// Contains the success value
|
||||
|
@ -17,7 +17,7 @@
|
||||
use mem::transmute;
|
||||
use clone::Clone;
|
||||
use container::Container;
|
||||
use cmp::{PartialEq, TotalOrd, Ordering, Less, Equal, Greater};
|
||||
use cmp::{PartialEq, Ord, Ordering, Less, Equal, Greater};
|
||||
use cmp;
|
||||
use default::Default;
|
||||
use iter::*;
|
||||
@ -251,7 +251,7 @@ impl<'a, T> RandomAccessIterator<&'a [T]> for Chunks<'a, T> {
|
||||
pub mod traits {
|
||||
use super::*;
|
||||
|
||||
use cmp::{PartialEq, PartialOrd, TotalEq, TotalOrd, Ordering, Equiv};
|
||||
use cmp::{PartialEq, PartialOrd, Eq, Ord, Ordering, Equiv};
|
||||
use iter::{order, Iterator};
|
||||
use container::Container;
|
||||
|
||||
@ -273,9 +273,9 @@ pub mod traits {
|
||||
fn ne(&self, other: &~[T]) -> bool { !self.eq(other) }
|
||||
}
|
||||
|
||||
impl<'a,T:TotalEq> TotalEq for &'a [T] {}
|
||||
impl<'a,T:Eq> Eq for &'a [T] {}
|
||||
|
||||
impl<T:TotalEq> TotalEq for ~[T] {}
|
||||
impl<T:Eq> Eq for ~[T] {}
|
||||
|
||||
impl<'a,T:PartialEq, V: Vector<T>> Equiv<V> for &'a [T] {
|
||||
#[inline]
|
||||
@ -287,13 +287,13 @@ pub mod traits {
|
||||
fn equiv(&self, other: &V) -> bool { self.as_slice() == other.as_slice() }
|
||||
}
|
||||
|
||||
impl<'a,T:TotalOrd> TotalOrd for &'a [T] {
|
||||
impl<'a,T:Ord> Ord for &'a [T] {
|
||||
fn cmp(&self, other: & &'a [T]) -> Ordering {
|
||||
order::cmp(self.iter(), other.iter())
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: TotalOrd> TotalOrd for ~[T] {
|
||||
impl<T: Ord> Ord for ~[T] {
|
||||
#[inline]
|
||||
fn cmp(&self, other: &~[T]) -> Ordering { self.as_slice().cmp(&other.as_slice()) }
|
||||
}
|
||||
@ -741,8 +741,8 @@ impl<'a,T:PartialEq> ImmutableEqVector<T> for &'a [T] {
|
||||
}
|
||||
}
|
||||
|
||||
/// Extension methods for vectors containing `TotalOrd` elements.
|
||||
pub trait ImmutableTotalOrdVector<T: TotalOrd> {
|
||||
/// Extension methods for vectors containing `Ord` elements.
|
||||
pub trait ImmutableOrdVector<T: Ord> {
|
||||
/**
|
||||
* Binary search a sorted vector for a given element.
|
||||
*
|
||||
@ -751,7 +751,7 @@ pub trait ImmutableTotalOrdVector<T: TotalOrd> {
|
||||
fn bsearch_elem(&self, x: &T) -> Option<uint>;
|
||||
}
|
||||
|
||||
impl<'a, T: TotalOrd> ImmutableTotalOrdVector<T> for &'a [T] {
|
||||
impl<'a, T: Ord> ImmutableOrdVector<T> for &'a [T] {
|
||||
fn bsearch_elem(&self, x: &T) -> Option<uint> {
|
||||
self.bsearch(|p| p.cmp(x))
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ use mem;
|
||||
use char;
|
||||
use clone::Clone;
|
||||
use cmp;
|
||||
use cmp::{PartialEq, TotalEq};
|
||||
use cmp::{PartialEq, Eq};
|
||||
use container::Container;
|
||||
use default::Default;
|
||||
use iter::{Filter, Map, Iterator};
|
||||
@ -698,7 +698,7 @@ pub struct Utf16Items<'a> {
|
||||
iter: slice::Items<'a, u16>
|
||||
}
|
||||
/// The possibilities for values decoded from a `u16` stream.
|
||||
#[deriving(PartialEq, TotalEq, Clone, Show)]
|
||||
#[deriving(PartialEq, Eq, Clone, Show)]
|
||||
pub enum Utf16Item {
|
||||
/// A valid codepoint.
|
||||
ScalarValue(char),
|
||||
@ -932,12 +932,12 @@ Section: Trait implementations
|
||||
#[allow(missing_doc)]
|
||||
pub mod traits {
|
||||
use container::Container;
|
||||
use cmp::{TotalOrd, Ordering, Less, Equal, Greater, PartialEq, PartialOrd, Equiv, TotalEq};
|
||||
use cmp::{Ord, Ordering, Less, Equal, Greater, PartialEq, PartialOrd, Equiv, Eq};
|
||||
use iter::Iterator;
|
||||
use option::{Some, None};
|
||||
use str::{Str, StrSlice, eq_slice};
|
||||
|
||||
impl<'a> TotalOrd for &'a str {
|
||||
impl<'a> Ord for &'a str {
|
||||
#[inline]
|
||||
fn cmp(&self, other: & &'a str) -> Ordering {
|
||||
for (s_b, o_b) in self.bytes().zip(other.bytes()) {
|
||||
@ -961,7 +961,7 @@ pub mod traits {
|
||||
fn ne(&self, other: & &'a str) -> bool { !(*self).eq(other) }
|
||||
}
|
||||
|
||||
impl<'a> TotalEq for &'a str {}
|
||||
impl<'a> Eq for &'a str {}
|
||||
|
||||
impl<'a> PartialOrd for &'a str {
|
||||
#[inline]
|
||||
|
@ -28,9 +28,9 @@
|
||||
//!
|
||||
//! * `Clone`
|
||||
//! * `PartialEq`
|
||||
//! * `TotalEq`
|
||||
//! * `Eq`
|
||||
//! * `PartialOrd`
|
||||
//! * `TotalOrd`
|
||||
//! * `Ord`
|
||||
//! * `Default`
|
||||
//!
|
||||
//! # Examples
|
||||
@ -123,7 +123,7 @@ macro_rules! tuple_impls {
|
||||
}
|
||||
|
||||
#[cfg(not(test))]
|
||||
impl<$($T:TotalEq),+> TotalEq for ($($T,)+) {}
|
||||
impl<$($T:Eq),+> Eq for ($($T,)+) {}
|
||||
|
||||
#[cfg(not(test))]
|
||||
impl<$($T:PartialOrd + PartialEq),+> PartialOrd for ($($T,)+) {
|
||||
@ -146,7 +146,7 @@ macro_rules! tuple_impls {
|
||||
}
|
||||
|
||||
#[cfg(not(test))]
|
||||
impl<$($T:TotalOrd),+> TotalOrd for ($($T,)+) {
|
||||
impl<$($T:Ord),+> Ord for ($($T,)+) {
|
||||
#[inline]
|
||||
fn cmp(&self, other: &($($T,)+)) -> Ordering {
|
||||
lexical_cmp!($(self.$refN(), other.$refN()),+)
|
||||
@ -364,7 +364,7 @@ mod tests {
|
||||
assert!(((1.0, 2.0) < (2.0, nan)));
|
||||
assert!(!((2.0, 2.0) < (2.0, nan)));
|
||||
|
||||
// TotalOrd
|
||||
// Ord
|
||||
assert!(small.cmp(&small) == Equal);
|
||||
assert!(big.cmp(&big) == Equal);
|
||||
assert!(small.cmp(&big) == Less);
|
||||
|
@ -146,7 +146,7 @@ pub enum Method<'a> {
|
||||
}
|
||||
|
||||
/// A selector for what pluralization a plural method should take
|
||||
#[deriving(PartialEq, TotalEq, Hash)]
|
||||
#[deriving(PartialEq, Eq, Hash)]
|
||||
pub enum PluralSelector {
|
||||
/// One of the plural keywords should be used
|
||||
Keyword(PluralKeyword),
|
||||
@ -168,7 +168,7 @@ pub struct PluralArm<'a> {
|
||||
/// is specially placed in the `Plural` variant of `Method`.
|
||||
///
|
||||
/// http://www.icu-project.org/apiref/icu4c/classicu_1_1PluralRules.html
|
||||
#[deriving(PartialEq, TotalEq, Hash, Show)]
|
||||
#[deriving(PartialEq, Eq, Hash, Show)]
|
||||
#[allow(missing_doc)]
|
||||
pub enum PluralKeyword {
|
||||
/// The plural form for zero objects.
|
||||
|
@ -198,12 +198,12 @@ fn list_dir_sorted(path: &Path) -> Option<Vec<Path>> {
|
||||
/**
|
||||
* A compiled Unix shell style pattern.
|
||||
*/
|
||||
#[deriving(Clone, PartialEq, TotalEq, PartialOrd, TotalOrd, Hash, Default)]
|
||||
#[deriving(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
|
||||
pub struct Pattern {
|
||||
tokens: Vec<PatternToken>,
|
||||
}
|
||||
|
||||
#[deriving(Clone, PartialEq, TotalEq, PartialOrd, TotalOrd, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
enum PatternToken {
|
||||
Char(char),
|
||||
AnyChar,
|
||||
@ -212,7 +212,7 @@ enum PatternToken {
|
||||
AnyExcept(Vec<CharSpecifier> )
|
||||
}
|
||||
|
||||
#[deriving(Clone, PartialEq, TotalEq, PartialOrd, TotalOrd, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
enum CharSpecifier {
|
||||
SingleChar(char),
|
||||
CharRange(char, char)
|
||||
@ -596,7 +596,7 @@ fn chars_eq(a: char, b: char, case_sensitive: bool) -> bool {
|
||||
/**
|
||||
* Configuration options to modify the behaviour of `Pattern::matches_with(..)`
|
||||
*/
|
||||
#[deriving(Clone, PartialEq, TotalEq, PartialOrd, TotalOrd, Hash, Default)]
|
||||
#[deriving(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
|
||||
pub struct MatchOptions {
|
||||
|
||||
/**
|
||||
|
@ -89,7 +89,7 @@ impl PartialEq for BigUint {
|
||||
match self.cmp(other) { Equal => true, _ => false }
|
||||
}
|
||||
}
|
||||
impl TotalEq for BigUint {}
|
||||
impl Eq for BigUint {}
|
||||
|
||||
impl PartialOrd for BigUint {
|
||||
#[inline]
|
||||
@ -98,7 +98,7 @@ impl PartialOrd for BigUint {
|
||||
}
|
||||
}
|
||||
|
||||
impl TotalOrd for BigUint {
|
||||
impl Ord for BigUint {
|
||||
#[inline]
|
||||
fn cmp(&self, other: &BigUint) -> Ordering {
|
||||
let (s_len, o_len) = (self.data.len(), other.data.len());
|
||||
@ -786,7 +786,7 @@ fn get_radix_base(radix: uint) -> (DoubleBigDigit, uint) {
|
||||
}
|
||||
|
||||
/// A Sign is a `BigInt`'s composing element.
|
||||
#[deriving(PartialEq, PartialOrd, TotalEq, TotalOrd, Clone, Show)]
|
||||
#[deriving(PartialEq, PartialOrd, Eq, Ord, Clone, Show)]
|
||||
pub enum Sign { Minus, Zero, Plus }
|
||||
|
||||
impl Neg<Sign> for Sign {
|
||||
@ -815,7 +815,7 @@ impl PartialEq for BigInt {
|
||||
}
|
||||
}
|
||||
|
||||
impl TotalEq for BigInt {}
|
||||
impl Eq for BigInt {}
|
||||
|
||||
impl PartialOrd for BigInt {
|
||||
#[inline]
|
||||
@ -824,7 +824,7 @@ impl PartialOrd for BigInt {
|
||||
}
|
||||
}
|
||||
|
||||
impl TotalOrd for BigInt {
|
||||
impl Ord for BigInt {
|
||||
#[inline]
|
||||
fn cmp(&self, other: &BigInt) -> Ordering {
|
||||
let scmp = self.sign.cmp(&other.sign);
|
||||
|
@ -194,8 +194,8 @@ macro_rules! cmp_impl {
|
||||
}
|
||||
cmp_impl!(impl PartialEq, eq, ne)
|
||||
cmp_impl!(impl PartialOrd, lt, gt, le, ge)
|
||||
cmp_impl!(impl TotalEq, )
|
||||
cmp_impl!(impl TotalOrd, cmp -> cmp::Ordering)
|
||||
cmp_impl!(impl Eq, )
|
||||
cmp_impl!(impl Ord, cmp -> cmp::Ordering)
|
||||
|
||||
/* Arithmetic */
|
||||
// a/b * c/d = (a*c)/(b*d)
|
||||
|
@ -45,7 +45,7 @@ use syntax::attr::AttrMetaMethods;
|
||||
use syntax::crateid::CrateId;
|
||||
use syntax::parse::token;
|
||||
|
||||
#[deriving(Clone, PartialEq, PartialOrd, TotalOrd, TotalEq)]
|
||||
#[deriving(Clone, PartialEq, PartialOrd, Ord, Eq)]
|
||||
pub enum OutputType {
|
||||
OutputTypeBitcode,
|
||||
OutputTypeAssembly,
|
||||
|
@ -132,7 +132,7 @@ pub enum EntryFnType {
|
||||
EntryNone,
|
||||
}
|
||||
|
||||
#[deriving(PartialEq, PartialOrd, Clone, TotalOrd, TotalEq, Hash)]
|
||||
#[deriving(PartialEq, PartialOrd, Clone, Ord, Eq, Hash)]
|
||||
pub enum CrateType {
|
||||
CrateTypeExecutable,
|
||||
CrateTypeDylib,
|
||||
|
@ -188,13 +188,13 @@ pub struct Loan {
|
||||
cause: euv::LoanCause,
|
||||
}
|
||||
|
||||
#[deriving(PartialEq, TotalEq, Hash)]
|
||||
#[deriving(PartialEq, Eq, Hash)]
|
||||
pub enum LoanPath {
|
||||
LpVar(ast::NodeId), // `x` in doc.rs
|
||||
LpExtend(Rc<LoanPath>, mc::MutabilityCategory, LoanPathElem)
|
||||
}
|
||||
|
||||
#[deriving(PartialEq, TotalEq, Hash)]
|
||||
#[deriving(PartialEq, Eq, Hash)]
|
||||
pub enum LoanPathElem {
|
||||
LpDeref(mc::PointerKind), // `*LV` in doc.rs
|
||||
LpInterior(mc::InteriorKind) // `LV.f` in doc.rs
|
||||
|
@ -42,7 +42,7 @@ macro_rules! lets_do_this {
|
||||
$( $variant:ident, $name:expr, $method:ident; )*
|
||||
) => {
|
||||
|
||||
#[deriving(FromPrimitive, PartialEq, TotalEq, Hash)]
|
||||
#[deriving(FromPrimitive, PartialEq, Eq, Hash)]
|
||||
pub enum LangItem {
|
||||
$($variant),*
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ use syntax::parse::token;
|
||||
use syntax::visit::Visitor;
|
||||
use syntax::{ast, ast_util, visit};
|
||||
|
||||
#[deriving(Clone, Show, PartialEq, PartialOrd, TotalEq, TotalOrd, Hash)]
|
||||
#[deriving(Clone, Show, PartialEq, PartialOrd, Eq, Ord, Hash)]
|
||||
pub enum Lint {
|
||||
CTypes,
|
||||
UnusedImports,
|
||||
@ -135,12 +135,12 @@ pub fn level_to_str(lv: Level) -> &'static str {
|
||||
}
|
||||
}
|
||||
|
||||
#[deriving(Clone, PartialEq, PartialOrd, TotalEq, TotalOrd)]
|
||||
#[deriving(Clone, PartialEq, PartialOrd, Eq, Ord)]
|
||||
pub enum Level {
|
||||
Allow, Warn, Deny, Forbid
|
||||
}
|
||||
|
||||
#[deriving(Clone, PartialEq, PartialOrd, TotalEq, TotalOrd)]
|
||||
#[deriving(Clone, PartialEq, PartialOrd, Eq, Ord)]
|
||||
pub struct LintSpec {
|
||||
pub default: Level,
|
||||
pub lint: Lint,
|
||||
|
@ -99,7 +99,7 @@ pub struct CopiedUpvar {
|
||||
}
|
||||
|
||||
// different kinds of pointers:
|
||||
#[deriving(Clone, PartialEq, TotalEq, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Hash)]
|
||||
pub enum PointerKind {
|
||||
OwnedPtr,
|
||||
GcPtr,
|
||||
@ -109,26 +109,26 @@ pub enum PointerKind {
|
||||
|
||||
// We use the term "interior" to mean "something reachable from the
|
||||
// base without a pointer dereference", e.g. a field
|
||||
#[deriving(Clone, PartialEq, TotalEq, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Hash)]
|
||||
pub enum InteriorKind {
|
||||
InteriorField(FieldName),
|
||||
InteriorElement(ElementKind),
|
||||
}
|
||||
|
||||
#[deriving(Clone, PartialEq, TotalEq, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Hash)]
|
||||
pub enum FieldName {
|
||||
NamedField(ast::Name),
|
||||
PositionalField(uint)
|
||||
}
|
||||
|
||||
#[deriving(Clone, PartialEq, TotalEq, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Hash)]
|
||||
pub enum ElementKind {
|
||||
VecElement,
|
||||
StrElement,
|
||||
OtherElement,
|
||||
}
|
||||
|
||||
#[deriving(Clone, PartialEq, TotalEq, Hash, Show)]
|
||||
#[deriving(Clone, PartialEq, Eq, Hash, Show)]
|
||||
pub enum MutabilityCategory {
|
||||
McImmutable, // Immutable.
|
||||
McDeclared, // Directly declared as mutable.
|
||||
|
@ -109,7 +109,7 @@ enum PatternBindingMode {
|
||||
ArgumentIrrefutableMode,
|
||||
}
|
||||
|
||||
#[deriving(PartialEq, TotalEq, Hash)]
|
||||
#[deriving(PartialEq, Eq, Hash)]
|
||||
enum Namespace {
|
||||
TypeNS,
|
||||
ValueNS
|
||||
|
@ -82,7 +82,7 @@ impl Drop for Rvalue {
|
||||
fn drop(&mut self) { }
|
||||
}
|
||||
|
||||
#[deriving(PartialEq, TotalEq, Hash)]
|
||||
#[deriving(PartialEq, Eq, Hash)]
|
||||
pub enum RvalueMode {
|
||||
/// `val` is a pointer to the actual value (and thus has type *T)
|
||||
ByRef,
|
||||
|
@ -312,14 +312,14 @@ pub fn monomorphic_fn(ccx: &CrateContext,
|
||||
}
|
||||
|
||||
// Used to identify cached monomorphized functions and vtables
|
||||
#[deriving(PartialEq, TotalEq, Hash)]
|
||||
#[deriving(PartialEq, Eq, Hash)]
|
||||
pub struct MonoParamId {
|
||||
pub subst: ty::t,
|
||||
// Do we really need the vtables to be hashed? Isn't the type enough?
|
||||
pub vtables: Vec<MonoId>
|
||||
}
|
||||
|
||||
#[deriving(PartialEq, TotalEq, Hash)]
|
||||
#[deriving(PartialEq, Eq, Hash)]
|
||||
pub struct MonoId {
|
||||
pub def: ast::DefId,
|
||||
pub params: Vec<MonoParamId>
|
||||
|
@ -65,7 +65,7 @@ pub static INITIAL_DISCRIMINANT_VALUE: Disr = 0;
|
||||
|
||||
// Data types
|
||||
|
||||
#[deriving(PartialEq, TotalEq, Hash)]
|
||||
#[deriving(PartialEq, Eq, Hash)]
|
||||
pub struct field {
|
||||
pub ident: ast::Ident,
|
||||
pub mt: mt
|
||||
@ -121,13 +121,13 @@ impl Method {
|
||||
}
|
||||
}
|
||||
|
||||
#[deriving(Clone, PartialEq, TotalEq, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Hash)]
|
||||
pub struct mt {
|
||||
pub ty: t,
|
||||
pub mutbl: ast::Mutability,
|
||||
}
|
||||
|
||||
#[deriving(Clone, PartialEq, TotalEq, Hash, Encodable, Decodable, Show)]
|
||||
#[deriving(Clone, PartialEq, Eq, Hash, Encodable, Decodable, Show)]
|
||||
pub enum TraitStore {
|
||||
/// Box<Trait>
|
||||
UniqTraitStore,
|
||||
@ -145,7 +145,7 @@ pub struct field_ty {
|
||||
|
||||
// Contains information needed to resolve types and (in the future) look up
|
||||
// the types of AST nodes.
|
||||
#[deriving(PartialEq, TotalEq, Hash)]
|
||||
#[deriving(PartialEq, Eq, Hash)]
|
||||
pub struct creader_cache_key {
|
||||
pub cnum: CrateNum,
|
||||
pub pos: uint,
|
||||
@ -172,7 +172,7 @@ impl cmp::PartialEq for intern_key {
|
||||
}
|
||||
}
|
||||
|
||||
impl TotalEq for intern_key {}
|
||||
impl Eq for intern_key {}
|
||||
|
||||
impl<W:Writer> Hash<W> for intern_key {
|
||||
fn hash(&self, s: &mut W) {
|
||||
@ -387,7 +387,7 @@ pub struct t_box_ {
|
||||
enum t_opaque {}
|
||||
|
||||
#[allow(raw_pointer_deriving)]
|
||||
#[deriving(Clone, PartialEq, TotalEq, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Hash)]
|
||||
pub struct t { inner: *t_opaque }
|
||||
|
||||
impl fmt::Show for t {
|
||||
@ -415,14 +415,14 @@ pub fn type_needs_infer(t: t) -> bool {
|
||||
}
|
||||
pub fn type_id(t: t) -> uint { get(t).id }
|
||||
|
||||
#[deriving(Clone, PartialEq, TotalEq, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Hash)]
|
||||
pub struct BareFnTy {
|
||||
pub fn_style: ast::FnStyle,
|
||||
pub abi: abi::Abi,
|
||||
pub sig: FnSig,
|
||||
}
|
||||
|
||||
#[deriving(Clone, PartialEq, TotalEq, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Hash)]
|
||||
pub struct ClosureTy {
|
||||
pub fn_style: ast::FnStyle,
|
||||
pub onceness: ast::Onceness,
|
||||
@ -443,7 +443,7 @@ pub struct ClosureTy {
|
||||
* - `output` is the return type.
|
||||
* - `variadic` indicates whether this is a varidic function. (only true for foreign fns)
|
||||
*/
|
||||
#[deriving(Clone, PartialEq, TotalEq, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Hash)]
|
||||
pub struct FnSig {
|
||||
pub binder_id: ast::NodeId,
|
||||
pub inputs: Vec<t>,
|
||||
@ -451,14 +451,14 @@ pub struct FnSig {
|
||||
pub variadic: bool
|
||||
}
|
||||
|
||||
#[deriving(Clone, PartialEq, TotalEq, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Hash)]
|
||||
pub struct param_ty {
|
||||
pub idx: uint,
|
||||
pub def_id: DefId
|
||||
}
|
||||
|
||||
/// Representation of regions:
|
||||
#[deriving(Clone, PartialEq, TotalEq, Hash, Encodable, Decodable, Show)]
|
||||
#[deriving(Clone, PartialEq, Eq, Hash, Encodable, Decodable, Show)]
|
||||
pub enum Region {
|
||||
// Region bound in a type or fn declaration which will be
|
||||
// substituted 'early' -- that is, at the same time when type
|
||||
@ -499,13 +499,13 @@ pub enum Region {
|
||||
* the original var id (that is, the root variable that is referenced
|
||||
* by the upvar) and the id of the closure expression.
|
||||
*/
|
||||
#[deriving(Clone, PartialEq, TotalEq, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Hash)]
|
||||
pub struct UpvarId {
|
||||
pub var_id: ast::NodeId,
|
||||
pub closure_expr_id: ast::NodeId,
|
||||
}
|
||||
|
||||
#[deriving(Clone, PartialEq, TotalEq, Hash, Show)]
|
||||
#[deriving(Clone, PartialEq, Eq, Hash, Show)]
|
||||
pub enum BorrowKind {
|
||||
/// Data must be immutable and is aliasable.
|
||||
ImmBorrow,
|
||||
@ -618,13 +618,13 @@ impl Region {
|
||||
}
|
||||
}
|
||||
|
||||
#[deriving(Clone, PartialEq, PartialOrd, TotalEq, TotalOrd, Hash, Encodable, Decodable, Show)]
|
||||
#[deriving(Clone, PartialEq, PartialOrd, Eq, Ord, Hash, Encodable, Decodable, Show)]
|
||||
pub struct FreeRegion {
|
||||
pub scope_id: NodeId,
|
||||
pub bound_region: BoundRegion
|
||||
}
|
||||
|
||||
#[deriving(Clone, PartialEq, PartialOrd, TotalEq, TotalOrd, Hash, Encodable, Decodable, Show)]
|
||||
#[deriving(Clone, PartialEq, PartialOrd, Eq, Ord, Hash, Encodable, Decodable, Show)]
|
||||
pub enum BoundRegion {
|
||||
/// An anonymous region parameter for a given fn (&T)
|
||||
BrAnon(uint),
|
||||
@ -643,7 +643,7 @@ pub enum BoundRegion {
|
||||
* Represents the values to use when substituting lifetime parameters.
|
||||
* If the value is `ErasedRegions`, then this subst is occurring during
|
||||
* trans, and all region parameters will be replaced with `ty::ReStatic`. */
|
||||
#[deriving(Clone, PartialEq, TotalEq, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Hash)]
|
||||
pub enum RegionSubsts {
|
||||
ErasedRegions,
|
||||
NonerasedRegions(OwnedSlice<ty::Region>)
|
||||
@ -666,7 +666,7 @@ pub enum RegionSubsts {
|
||||
* - `self_ty` is the type to which `self` should be remapped, if any. The
|
||||
* `self` type is rather funny in that it can only appear on traits and is
|
||||
* always substituted away to the implementing type for a trait. */
|
||||
#[deriving(Clone, PartialEq, TotalEq, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Hash)]
|
||||
pub struct substs {
|
||||
pub self_ty: Option<ty::t>,
|
||||
pub tps: Vec<t>,
|
||||
@ -722,7 +722,7 @@ mod primitives {
|
||||
|
||||
// NB: If you change this, you'll probably want to change the corresponding
|
||||
// AST structure in libsyntax/ast.rs as well.
|
||||
#[deriving(Clone, PartialEq, TotalEq, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Hash)]
|
||||
pub enum sty {
|
||||
ty_nil,
|
||||
ty_bot,
|
||||
@ -754,7 +754,7 @@ pub enum sty {
|
||||
// on non-useful type error messages)
|
||||
}
|
||||
|
||||
#[deriving(Clone, PartialEq, TotalEq, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Hash)]
|
||||
pub struct TyTrait {
|
||||
pub def_id: DefId,
|
||||
pub substs: substs,
|
||||
@ -762,7 +762,7 @@ pub struct TyTrait {
|
||||
pub bounds: BuiltinBounds
|
||||
}
|
||||
|
||||
#[deriving(PartialEq, TotalEq, Hash)]
|
||||
#[deriving(PartialEq, Eq, Hash)]
|
||||
pub struct TraitRef {
|
||||
pub def_id: DefId,
|
||||
pub substs: substs
|
||||
@ -822,7 +822,7 @@ pub enum type_err {
|
||||
terr_variadic_mismatch(expected_found<bool>)
|
||||
}
|
||||
|
||||
#[deriving(PartialEq, TotalEq, Hash)]
|
||||
#[deriving(PartialEq, Eq, Hash)]
|
||||
pub struct ParamBounds {
|
||||
pub builtin_bounds: BuiltinBounds,
|
||||
pub trait_bounds: Vec<Rc<TraitRef>>
|
||||
@ -830,7 +830,7 @@ pub struct ParamBounds {
|
||||
|
||||
pub type BuiltinBounds = EnumSet<BuiltinBound>;
|
||||
|
||||
#[deriving(Clone, Encodable, PartialEq, TotalEq, Decodable, Hash, Show)]
|
||||
#[deriving(Clone, Encodable, PartialEq, Eq, Decodable, Hash, Show)]
|
||||
#[repr(uint)]
|
||||
pub enum BuiltinBound {
|
||||
BoundStatic,
|
||||
@ -862,28 +862,28 @@ impl CLike for BuiltinBound {
|
||||
}
|
||||
}
|
||||
|
||||
#[deriving(Clone, PartialEq, TotalEq, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Hash)]
|
||||
pub struct TyVid(pub uint);
|
||||
|
||||
#[deriving(Clone, PartialEq, TotalEq, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Hash)]
|
||||
pub struct IntVid(pub uint);
|
||||
|
||||
#[deriving(Clone, PartialEq, TotalEq, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Hash)]
|
||||
pub struct FloatVid(pub uint);
|
||||
|
||||
#[deriving(Clone, PartialEq, TotalEq, Encodable, Decodable, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
|
||||
pub struct RegionVid {
|
||||
pub id: uint
|
||||
}
|
||||
|
||||
#[deriving(Clone, PartialEq, TotalEq, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Hash)]
|
||||
pub enum InferTy {
|
||||
TyVar(TyVid),
|
||||
IntVar(IntVid),
|
||||
FloatVar(FloatVid)
|
||||
}
|
||||
|
||||
#[deriving(Clone, Encodable, Decodable, TotalEq, Hash, Show)]
|
||||
#[deriving(Clone, Encodable, Decodable, Eq, Hash, Show)]
|
||||
pub enum InferRegion {
|
||||
ReVar(RegionVid),
|
||||
ReSkolemized(uint, BoundRegion)
|
||||
|
@ -31,7 +31,7 @@ use syntax::ast;
|
||||
|
||||
mod doc;
|
||||
|
||||
#[deriving(PartialEq, TotalEq, Hash)]
|
||||
#[deriving(PartialEq, Eq, Hash)]
|
||||
pub enum Constraint {
|
||||
ConstrainVarSubVar(RegionVid, RegionVid),
|
||||
ConstrainRegSubVar(Region, RegionVid),
|
||||
@ -39,7 +39,7 @@ pub enum Constraint {
|
||||
ConstrainRegSubReg(Region, Region),
|
||||
}
|
||||
|
||||
#[deriving(PartialEq, TotalEq, Hash)]
|
||||
#[deriving(PartialEq, Eq, Hash)]
|
||||
pub struct TwoRegions {
|
||||
a: Region,
|
||||
b: Region,
|
||||
|
@ -147,7 +147,7 @@ pub struct MethodCallee {
|
||||
pub substs: ty::substs
|
||||
}
|
||||
|
||||
#[deriving(Clone, PartialEq, TotalEq, Hash, Show)]
|
||||
#[deriving(Clone, PartialEq, Eq, Hash, Show)]
|
||||
pub struct MethodCall {
|
||||
pub expr_id: ast::NodeId,
|
||||
pub autoderef: u32
|
||||
|
@ -28,14 +28,14 @@ pub type DefIdSet = FnvHashSet<ast::DefId>;
|
||||
pub mod FnvHashMap {
|
||||
use std::hash::Hash;
|
||||
use collections::HashMap;
|
||||
pub fn new<K: Hash<super::FnvState> + TotalEq, V>() -> super::FnvHashMap<K, V> {
|
||||
pub fn new<K: Hash<super::FnvState> + Eq, V>() -> super::FnvHashMap<K, V> {
|
||||
HashMap::with_hasher(super::FnvHasher)
|
||||
}
|
||||
}
|
||||
pub mod FnvHashSet {
|
||||
use std::hash::Hash;
|
||||
use collections::HashSet;
|
||||
pub fn new<V: Hash<super::FnvState> + TotalEq>() -> super::FnvHashSet<V> {
|
||||
pub fn new<V: Hash<super::FnvState> + Eq>() -> super::FnvHashSet<V> {
|
||||
HashSet::with_hasher(super::FnvHasher)
|
||||
}
|
||||
}
|
||||
|
@ -1028,7 +1028,7 @@ pub enum Type {
|
||||
// region, raw, other boxes, mutable
|
||||
}
|
||||
|
||||
#[deriving(Clone, Encodable, Decodable, PartialEq, TotalEq, Hash)]
|
||||
#[deriving(Clone, Encodable, Decodable, PartialEq, Eq, Hash)]
|
||||
pub enum Primitive {
|
||||
Int, I8, I16, I32, I64,
|
||||
Uint, U8, U16, U32, U64,
|
||||
|
@ -76,7 +76,7 @@ impl<E, D:Decoder<E>,T:Decodable<D, E>> Decodable<D, E> for RingBuf<T> {
|
||||
impl<
|
||||
E,
|
||||
S: Encoder<E>,
|
||||
K: Encodable<S, E> + PartialEq + TotalOrd,
|
||||
K: Encodable<S, E> + PartialEq + Ord,
|
||||
V: Encodable<S, E> + PartialEq
|
||||
> Encodable<S, E> for TreeMap<K, V> {
|
||||
fn encode(&self, e: &mut S) -> Result<(), E> {
|
||||
@ -95,7 +95,7 @@ impl<
|
||||
impl<
|
||||
E,
|
||||
D: Decoder<E>,
|
||||
K: Decodable<D, E> + PartialEq + TotalOrd,
|
||||
K: Decodable<D, E> + PartialEq + Ord,
|
||||
V: Decodable<D, E> + PartialEq
|
||||
> Decodable<D, E> for TreeMap<K, V> {
|
||||
fn decode(d: &mut D) -> Result<TreeMap<K, V>, E> {
|
||||
@ -114,7 +114,7 @@ impl<
|
||||
impl<
|
||||
E,
|
||||
S: Encoder<E>,
|
||||
T: Encodable<S, E> + PartialEq + TotalOrd
|
||||
T: Encodable<S, E> + PartialEq + Ord
|
||||
> Encodable<S, E> for TreeSet<T> {
|
||||
fn encode(&self, s: &mut S) -> Result<(), E> {
|
||||
s.emit_seq(self.len(), |s| {
|
||||
@ -131,7 +131,7 @@ impl<
|
||||
impl<
|
||||
E,
|
||||
D: Decoder<E>,
|
||||
T: Decodable<D, E> + PartialEq + TotalOrd
|
||||
T: Decodable<D, E> + PartialEq + Ord
|
||||
> Decodable<D, E> for TreeSet<T> {
|
||||
fn decode(d: &mut D) -> Result<TreeSet<T>, E> {
|
||||
d.read_seq(|d, len| {
|
||||
@ -178,7 +178,7 @@ impl<
|
||||
impl<
|
||||
E,
|
||||
S: Encoder<E>,
|
||||
K: Encodable<S, E> + Hash<X> + TotalEq,
|
||||
K: Encodable<S, E> + Hash<X> + Eq,
|
||||
V: Encodable<S, E>,
|
||||
X,
|
||||
H: Hasher<X>
|
||||
@ -199,7 +199,7 @@ impl<
|
||||
impl<
|
||||
E,
|
||||
D: Decoder<E>,
|
||||
K: Decodable<D, E> + Hash<S> + TotalEq,
|
||||
K: Decodable<D, E> + Hash<S> + Eq,
|
||||
V: Decodable<D, E>,
|
||||
S,
|
||||
H: Hasher<S> + Default
|
||||
@ -221,7 +221,7 @@ impl<
|
||||
impl<
|
||||
E,
|
||||
S: Encoder<E>,
|
||||
T: Encodable<S, E> + Hash<X> + TotalEq,
|
||||
T: Encodable<S, E> + Hash<X> + Eq,
|
||||
X,
|
||||
H: Hasher<X>
|
||||
> Encodable<S, E> for HashSet<T, H> {
|
||||
@ -240,7 +240,7 @@ impl<
|
||||
impl<
|
||||
E,
|
||||
D: Decoder<E>,
|
||||
T: Decodable<D, E> + Hash<S> + TotalEq,
|
||||
T: Decodable<D, E> + Hash<S> + Eq,
|
||||
S,
|
||||
H: Hasher<S> + Default
|
||||
> Decodable<D, E> for HashSet<T, H> {
|
||||
|
@ -23,7 +23,7 @@ use to_str::{IntoStr};
|
||||
use vec::Vec;
|
||||
|
||||
/// Datatype to hold one ascii character. It wraps a `u8`, with the highest bit always zero.
|
||||
#[deriving(Clone, PartialEq, PartialOrd, TotalOrd, TotalEq, Hash)]
|
||||
#[deriving(Clone, PartialEq, PartialOrd, Ord, Eq, Hash)]
|
||||
pub struct Ascii { chr: u8 }
|
||||
|
||||
impl Ascii {
|
||||
|
@ -112,7 +112,7 @@ macro_rules! bitflags(
|
||||
($(#[$attr:meta])* flags $BitFlags:ident: $T:ty {
|
||||
$($(#[$Flag_attr:meta])* static $Flag:ident = $value:expr),+
|
||||
}) => (
|
||||
#[deriving(PartialEq, TotalEq, Clone)]
|
||||
#[deriving(PartialEq, Eq, Clone)]
|
||||
$(#[$attr])*
|
||||
pub struct $BitFlags {
|
||||
bits: $T,
|
||||
|
@ -25,7 +25,7 @@ use slice::{MutableCloneableVector, ImmutableVector, MutableVector};
|
||||
|
||||
pub type Port = u16;
|
||||
|
||||
#[deriving(PartialEq, TotalEq, Clone, Hash)]
|
||||
#[deriving(PartialEq, Eq, Clone, Hash)]
|
||||
pub enum IpAddr {
|
||||
Ipv4Addr(u8, u8, u8, u8),
|
||||
Ipv6Addr(u16, u16, u16, u16, u16, u16, u16, u16)
|
||||
@ -56,7 +56,7 @@ impl fmt::Show for IpAddr {
|
||||
}
|
||||
}
|
||||
|
||||
#[deriving(PartialEq, TotalEq, Clone, Hash)]
|
||||
#[deriving(PartialEq, Eq, Clone, Hash)]
|
||||
pub struct SocketAddr {
|
||||
pub ip: IpAddr,
|
||||
pub port: Port,
|
||||
|
@ -317,7 +317,7 @@ impl fmt::Show for Command {
|
||||
}
|
||||
|
||||
/// The output of a finished process.
|
||||
#[deriving(PartialEq, TotalEq, Clone)]
|
||||
#[deriving(PartialEq, Eq, Clone)]
|
||||
pub struct ProcessOutput {
|
||||
/// The status (exit code) of the process.
|
||||
pub status: ProcessExit,
|
||||
@ -348,7 +348,7 @@ pub enum StdioContainer {
|
||||
|
||||
/// Describes the result of a process after it has terminated.
|
||||
/// Note that Windows have no signals, so the result is usually ExitStatus.
|
||||
#[deriving(PartialEq, TotalEq, Clone)]
|
||||
#[deriving(PartialEq, Eq, Clone)]
|
||||
pub enum ProcessExit {
|
||||
/// Normal termination with an exit status.
|
||||
ExitStatus(int),
|
||||
|
@ -13,7 +13,7 @@
|
||||
use container::Container;
|
||||
use c_str::{CString, ToCStr};
|
||||
use clone::Clone;
|
||||
use cmp::{PartialEq, TotalEq};
|
||||
use cmp::{PartialEq, Eq};
|
||||
use from_str::FromStr;
|
||||
use io::Writer;
|
||||
use iter::{DoubleEndedIterator, AdditiveIterator, Extendable, Iterator, Map};
|
||||
@ -65,7 +65,7 @@ impl PartialEq for Path {
|
||||
}
|
||||
}
|
||||
|
||||
impl TotalEq for Path {}
|
||||
impl Eq for Path {}
|
||||
|
||||
impl FromStr for Path {
|
||||
fn from_str(s: &str) -> Option<Path> {
|
||||
|
@ -13,7 +13,7 @@
|
||||
use ascii::AsciiCast;
|
||||
use c_str::{CString, ToCStr};
|
||||
use clone::Clone;
|
||||
use cmp::{PartialEq, TotalEq};
|
||||
use cmp::{PartialEq, Eq};
|
||||
use container::Container;
|
||||
use from_str::FromStr;
|
||||
use io::Writer;
|
||||
@ -86,7 +86,7 @@ impl PartialEq for Path {
|
||||
}
|
||||
}
|
||||
|
||||
impl TotalEq for Path {}
|
||||
impl Eq for Path {}
|
||||
|
||||
impl FromStr for Path {
|
||||
fn from_str(s: &str) -> Option<Path> {
|
||||
|
@ -58,7 +58,7 @@
|
||||
#[doc(no_inline)] pub use c_str::ToCStr;
|
||||
#[doc(no_inline)] pub use char::Char;
|
||||
#[doc(no_inline)] pub use clone::Clone;
|
||||
#[doc(no_inline)] pub use cmp::{PartialEq, PartialOrd, TotalEq, TotalOrd};
|
||||
#[doc(no_inline)] pub use cmp::{PartialEq, PartialOrd, Eq, Ord};
|
||||
#[doc(no_inline)] pub use cmp::{Ordering, Less, Equal, Greater, Equiv};
|
||||
#[doc(no_inline)] pub use container::{Container, Mutable, Map, MutableMap};
|
||||
#[doc(no_inline)] pub use container::{Set, MutableSet};
|
||||
@ -81,9 +81,9 @@
|
||||
#[doc(no_inline)] pub use tuple::{Tuple5, Tuple6, Tuple7, Tuple8};
|
||||
#[doc(no_inline)] pub use tuple::{Tuple9, Tuple10, Tuple11, Tuple12};
|
||||
#[doc(no_inline)] pub use slice::{CloneableVector, ImmutableCloneableVector};
|
||||
#[doc(no_inline)] pub use slice::{MutableCloneableVector, MutableTotalOrdVector};
|
||||
#[doc(no_inline)] pub use slice::{MutableCloneableVector, MutableOrdVector};
|
||||
#[doc(no_inline)] pub use slice::{ImmutableVector, MutableVector};
|
||||
#[doc(no_inline)] pub use slice::{ImmutableEqVector, ImmutableTotalOrdVector};
|
||||
#[doc(no_inline)] pub use slice::{ImmutableEqVector, ImmutableOrdVector};
|
||||
#[doc(no_inline)] pub use slice::{Vector, VectorVector, OwnedVector};
|
||||
#[doc(no_inline)] pub use slice::MutableVectorAllocating;
|
||||
#[doc(no_inline)] pub use string::String;
|
||||
|
@ -65,7 +65,7 @@ Vectors are a very useful type, and so there's several implementations of
|
||||
traits from other modules. Some notable examples:
|
||||
|
||||
* `Clone`
|
||||
* `Eq`, `Ord`, `TotalEq`, `TotalOrd` -- vectors can be compared,
|
||||
* `Eq`, `Ord`, `Eq`, `Ord` -- vectors can be compared,
|
||||
if the element type defines the corresponding trait.
|
||||
|
||||
## Iteration
|
||||
@ -101,7 +101,7 @@ There are a number of free functions that create or take vectors, for example:
|
||||
|
||||
use mem::transmute;
|
||||
use clone::Clone;
|
||||
use cmp::{TotalOrd, Ordering, Less, Greater};
|
||||
use cmp::{Ord, Ordering, Less, Greater};
|
||||
use cmp;
|
||||
use container::Container;
|
||||
use iter::*;
|
||||
@ -117,7 +117,7 @@ use vec::Vec;
|
||||
|
||||
pub use core::slice::{ref_slice, mut_ref_slice, Splits, Windows};
|
||||
pub use core::slice::{Chunks, Vector, ImmutableVector, ImmutableEqVector};
|
||||
pub use core::slice::{ImmutableTotalOrdVector, MutableVector, Items, MutItems};
|
||||
pub use core::slice::{ImmutableOrdVector, MutableVector, Items, MutItems};
|
||||
pub use core::slice::{MutSplits, MutChunks};
|
||||
pub use core::slice::{bytes, MutableCloneableVector};
|
||||
|
||||
@ -698,7 +698,7 @@ impl<'a,T> MutableVectorAllocating<'a, T> for &'a mut [T] {
|
||||
|
||||
/// Methods for mutable vectors with orderable elements, such as
|
||||
/// in-place sorting.
|
||||
pub trait MutableTotalOrdVector<T> {
|
||||
pub trait MutableOrdVector<T> {
|
||||
/// Sort the vector, in place.
|
||||
///
|
||||
/// This is equivalent to `self.sort_by(|a, b| a.cmp(b))`.
|
||||
@ -714,7 +714,7 @@ pub trait MutableTotalOrdVector<T> {
|
||||
fn sort(self);
|
||||
}
|
||||
|
||||
impl<'a, T: TotalOrd> MutableTotalOrdVector<T> for &'a mut [T] {
|
||||
impl<'a, T: Ord> MutableOrdVector<T> for &'a mut [T] {
|
||||
#[inline]
|
||||
fn sort(self) {
|
||||
self.sort_by(|a,b| a.cmp(b))
|
||||
|
@ -70,7 +70,7 @@ is the same as `&[u8]`.
|
||||
use char::Char;
|
||||
use char;
|
||||
use clone::Clone;
|
||||
use cmp::{PartialEq, TotalEq, PartialOrd, TotalOrd, Equiv, Ordering};
|
||||
use cmp::{PartialEq, Eq, PartialOrd, Ord, Equiv, Ordering};
|
||||
use container::Container;
|
||||
use default::Default;
|
||||
use fmt;
|
||||
@ -575,7 +575,7 @@ impl<'a> PartialEq for MaybeOwned<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> TotalEq for MaybeOwned<'a> {}
|
||||
impl<'a> Eq for MaybeOwned<'a> {}
|
||||
|
||||
impl<'a> PartialOrd for MaybeOwned<'a> {
|
||||
#[inline]
|
||||
@ -584,7 +584,7 @@ impl<'a> PartialOrd for MaybeOwned<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> TotalOrd for MaybeOwned<'a> {
|
||||
impl<'a> Ord for MaybeOwned<'a> {
|
||||
#[inline]
|
||||
fn cmp(&self, other: &MaybeOwned) -> Ordering {
|
||||
self.as_slice().cmp(&other.as_slice())
|
||||
|
@ -30,7 +30,7 @@ use str;
|
||||
use vec::Vec;
|
||||
|
||||
/// A growable string stored as a UTF-8 encoded buffer.
|
||||
#[deriving(Clone, PartialEq, PartialOrd, TotalEq, TotalOrd)]
|
||||
#[deriving(Clone, PartialEq, PartialOrd, Eq, Ord)]
|
||||
pub struct String {
|
||||
vec: Vec<u8>,
|
||||
}
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
use RawVec = raw::Vec;
|
||||
use clone::Clone;
|
||||
use cmp::{PartialOrd, PartialEq, Ordering, TotalEq, TotalOrd, max};
|
||||
use cmp::{PartialOrd, PartialEq, Ordering, Eq, Ord, max};
|
||||
use container::{Container, Mutable};
|
||||
use default::Default;
|
||||
use fmt;
|
||||
@ -27,7 +27,7 @@ use ptr;
|
||||
use raw::Slice;
|
||||
use rt::heap::{allocate, reallocate, deallocate};
|
||||
use slice::{ImmutableEqVector, ImmutableVector, Items, MutItems, MutableVector};
|
||||
use slice::{MutableTotalOrdVector, OwnedVector, Vector};
|
||||
use slice::{MutableOrdVector, OwnedVector, Vector};
|
||||
use slice::{MutableVectorAllocating};
|
||||
|
||||
/// An owned, growable vector.
|
||||
@ -388,9 +388,9 @@ impl<T: PartialOrd> PartialOrd for Vec<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: TotalEq> TotalEq for Vec<T> {}
|
||||
impl<T: Eq> Eq for Vec<T> {}
|
||||
|
||||
impl<T: TotalOrd> TotalOrd for Vec<T> {
|
||||
impl<T: Ord> Ord for Vec<T> {
|
||||
#[inline]
|
||||
fn cmp(&self, other: &Vec<T>) -> Ordering {
|
||||
self.as_slice().cmp(&other.as_slice())
|
||||
@ -1263,7 +1263,7 @@ impl<T> Vec<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T:TotalOrd> Vec<T> {
|
||||
impl<T:Ord> Vec<T> {
|
||||
/// Sorts the vector in place.
|
||||
///
|
||||
/// This sort is `O(n log n)` worst-case and stable, but allocates
|
||||
|
@ -13,7 +13,7 @@ use std::fmt;
|
||||
#[deriving(PartialEq)]
|
||||
pub enum Os { OsWin32, OsMacos, OsLinux, OsAndroid, OsFreebsd, }
|
||||
|
||||
#[deriving(PartialEq, TotalEq, Hash, Encodable, Decodable, Clone)]
|
||||
#[deriving(PartialEq, Eq, Hash, Encodable, Decodable, Clone)]
|
||||
pub enum Abi {
|
||||
// NB: This ordering MUST match the AbiDatas array below.
|
||||
// (This is ensured by the test indices_are_correct().)
|
||||
|
@ -39,7 +39,7 @@ pub fn P<T: 'static>(value: T) -> P<T> {
|
||||
// table) and a SyntaxContext to track renaming and
|
||||
// macro expansion per Flatt et al., "Macros
|
||||
// That Work Together"
|
||||
#[deriving(Clone, Hash, PartialOrd, TotalEq, TotalOrd, Show)]
|
||||
#[deriving(Clone, Hash, PartialOrd, Eq, Ord, Show)]
|
||||
pub struct Ident {
|
||||
pub name: Name,
|
||||
pub ctxt: SyntaxContext
|
||||
@ -114,7 +114,7 @@ impl<D:Decoder<E>, E> Decodable<D, E> for Ident {
|
||||
/// Function name (not all functions have names)
|
||||
pub type FnIdent = Option<Ident>;
|
||||
|
||||
#[deriving(Clone, PartialEq, TotalEq, Encodable, Decodable, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
|
||||
pub struct Lifetime {
|
||||
pub id: NodeId,
|
||||
pub span: Span,
|
||||
@ -125,7 +125,7 @@ pub struct Lifetime {
|
||||
// for instance: std::cmp::PartialEq . It's represented
|
||||
// as a sequence of identifiers, along with a bunch
|
||||
// of supporting information.
|
||||
#[deriving(Clone, PartialEq, TotalEq, Encodable, Decodable, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
|
||||
pub struct Path {
|
||||
pub span: Span,
|
||||
/// A `::foo` path, is relative to the crate root rather than current
|
||||
@ -137,7 +137,7 @@ pub struct Path {
|
||||
|
||||
/// A segment of a path: an identifier, an optional lifetime, and a set of
|
||||
/// types.
|
||||
#[deriving(Clone, PartialEq, TotalEq, Encodable, Decodable, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
|
||||
pub struct PathSegment {
|
||||
/// The identifier portion of this path segment.
|
||||
pub identifier: Ident,
|
||||
@ -151,7 +151,7 @@ pub type CrateNum = u32;
|
||||
|
||||
pub type NodeId = u32;
|
||||
|
||||
#[deriving(Clone, TotalEq, TotalOrd, PartialOrd, PartialEq, Encodable, Decodable, Hash, Show)]
|
||||
#[deriving(Clone, Eq, Ord, PartialOrd, PartialEq, Encodable, Decodable, Hash, Show)]
|
||||
pub struct DefId {
|
||||
pub krate: CrateNum,
|
||||
pub node: NodeId,
|
||||
@ -171,14 +171,14 @@ pub static DUMMY_NODE_ID: NodeId = -1;
|
||||
// typeck::collect::compute_bounds matches these against
|
||||
// the "special" built-in traits (see middle::lang_items) and
|
||||
// detects Copy, Send and Share.
|
||||
#[deriving(Clone, PartialEq, TotalEq, Encodable, Decodable, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
|
||||
pub enum TyParamBound {
|
||||
TraitTyParamBound(TraitRef),
|
||||
StaticRegionTyParamBound,
|
||||
OtherRegionTyParamBound(Span) // FIXME -- just here until work for #5723 lands
|
||||
}
|
||||
|
||||
#[deriving(Clone, PartialEq, TotalEq, Encodable, Decodable, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
|
||||
pub struct TyParam {
|
||||
pub ident: Ident,
|
||||
pub id: NodeId,
|
||||
@ -188,7 +188,7 @@ pub struct TyParam {
|
||||
pub span: Span
|
||||
}
|
||||
|
||||
#[deriving(Clone, PartialEq, TotalEq, Encodable, Decodable, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
|
||||
pub struct Generics {
|
||||
pub lifetimes: Vec<Lifetime>,
|
||||
pub ty_params: OwnedSlice<TyParam>,
|
||||
@ -206,13 +206,13 @@ impl Generics {
|
||||
}
|
||||
}
|
||||
|
||||
#[deriving(Clone, PartialEq, TotalEq, Encodable, Decodable, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
|
||||
pub enum MethodProvenance {
|
||||
FromTrait(DefId),
|
||||
FromImpl(DefId),
|
||||
}
|
||||
|
||||
#[deriving(Clone, PartialEq, TotalEq, Encodable, Decodable, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
|
||||
pub enum Def {
|
||||
DefFn(DefId, FnStyle),
|
||||
DefStaticMethod(/* method */ DefId, MethodProvenance, FnStyle),
|
||||
@ -249,7 +249,7 @@ pub enum Def {
|
||||
DefMethod(DefId /* method */, Option<DefId> /* trait */),
|
||||
}
|
||||
|
||||
#[deriving(Clone, PartialEq, TotalEq, Hash, Encodable, Decodable, Show)]
|
||||
#[deriving(Clone, PartialEq, Eq, Hash, Encodable, Decodable, Show)]
|
||||
pub enum DefRegion {
|
||||
DefStaticRegion,
|
||||
DefEarlyBoundRegion(/* index */ uint, /* lifetime decl */ NodeId),
|
||||
@ -261,7 +261,7 @@ pub enum DefRegion {
|
||||
// used to drive conditional compilation
|
||||
pub type CrateConfig = Vec<@MetaItem> ;
|
||||
|
||||
#[deriving(Clone, PartialEq, TotalEq, Encodable, Decodable, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
|
||||
pub struct Crate {
|
||||
pub module: Mod,
|
||||
pub attrs: Vec<Attribute>,
|
||||
@ -271,7 +271,7 @@ pub struct Crate {
|
||||
|
||||
pub type MetaItem = Spanned<MetaItem_>;
|
||||
|
||||
#[deriving(Clone, Encodable, Decodable, TotalEq, Hash)]
|
||||
#[deriving(Clone, Encodable, Decodable, Eq, Hash)]
|
||||
pub enum MetaItem_ {
|
||||
MetaWord(InternedString),
|
||||
MetaList(InternedString, Vec<@MetaItem> ),
|
||||
@ -303,7 +303,7 @@ impl PartialEq for MetaItem_ {
|
||||
}
|
||||
}
|
||||
|
||||
#[deriving(Clone, PartialEq, TotalEq, Encodable, Decodable, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
|
||||
pub struct Block {
|
||||
pub view_items: Vec<ViewItem>,
|
||||
pub stmts: Vec<@Stmt>,
|
||||
@ -313,26 +313,26 @@ pub struct Block {
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
#[deriving(Clone, PartialEq, TotalEq, Encodable, Decodable, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
|
||||
pub struct Pat {
|
||||
pub id: NodeId,
|
||||
pub node: Pat_,
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
#[deriving(Clone, PartialEq, TotalEq, Encodable, Decodable, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
|
||||
pub struct FieldPat {
|
||||
pub ident: Ident,
|
||||
pub pat: @Pat,
|
||||
}
|
||||
|
||||
#[deriving(Clone, PartialEq, TotalEq, Encodable, Decodable, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
|
||||
pub enum BindingMode {
|
||||
BindByRef(Mutability),
|
||||
BindByValue(Mutability),
|
||||
}
|
||||
|
||||
#[deriving(Clone, PartialEq, TotalEq, Encodable, Decodable, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
|
||||
pub enum Pat_ {
|
||||
PatWild,
|
||||
PatWildMulti,
|
||||
@ -358,20 +358,20 @@ pub enum Pat_ {
|
||||
PatMac(Mac),
|
||||
}
|
||||
|
||||
#[deriving(Clone, PartialEq, TotalEq, Encodable, Decodable, Hash, Show)]
|
||||
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
|
||||
pub enum Mutability {
|
||||
MutMutable,
|
||||
MutImmutable,
|
||||
}
|
||||
|
||||
#[deriving(Clone, PartialEq, TotalEq, Encodable, Decodable, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
|
||||
pub enum ExprVstore {
|
||||
ExprVstoreUniq, // ~[1,2,3,4]
|
||||
ExprVstoreSlice, // &[1,2,3,4]
|
||||
ExprVstoreMutSlice, // &mut [1,2,3,4]
|
||||
}
|
||||
|
||||
#[deriving(Clone, PartialEq, TotalEq, Encodable, Decodable, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
|
||||
pub enum BinOp {
|
||||
BiAdd,
|
||||
BiSub,
|
||||
@ -393,7 +393,7 @@ pub enum BinOp {
|
||||
BiGt,
|
||||
}
|
||||
|
||||
#[deriving(Clone, PartialEq, TotalEq, Encodable, Decodable, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
|
||||
pub enum UnOp {
|
||||
UnBox,
|
||||
UnUniq,
|
||||
@ -404,7 +404,7 @@ pub enum UnOp {
|
||||
|
||||
pub type Stmt = Spanned<Stmt_>;
|
||||
|
||||
#[deriving(Clone, PartialEq, TotalEq, Encodable, Decodable, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
|
||||
pub enum Stmt_ {
|
||||
// could be an item or a local (let) binding:
|
||||
StmtDecl(@Decl, NodeId),
|
||||
@ -421,7 +421,7 @@ pub enum Stmt_ {
|
||||
|
||||
/// Where a local declaration came from: either a true `let ... =
|
||||
/// ...;`, or one desugared from the pattern of a for loop.
|
||||
#[deriving(Clone, PartialEq, TotalEq, Encodable, Decodable, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
|
||||
pub enum LocalSource {
|
||||
LocalLet,
|
||||
LocalFor,
|
||||
@ -430,7 +430,7 @@ pub enum LocalSource {
|
||||
// FIXME (pending discussion of #1697, #2178...): local should really be
|
||||
// a refinement on pat.
|
||||
/// Local represents a `let` statement, e.g., `let <pat>:<ty> = <expr>;`
|
||||
#[deriving(PartialEq, TotalEq, Encodable, Decodable, Hash)]
|
||||
#[deriving(PartialEq, Eq, Encodable, Decodable, Hash)]
|
||||
pub struct Local {
|
||||
pub ty: P<Ty>,
|
||||
pub pat: @Pat,
|
||||
@ -442,7 +442,7 @@ pub struct Local {
|
||||
|
||||
pub type Decl = Spanned<Decl_>;
|
||||
|
||||
#[deriving(PartialEq, TotalEq, Encodable, Decodable, Hash)]
|
||||
#[deriving(PartialEq, Eq, Encodable, Decodable, Hash)]
|
||||
pub enum Decl_ {
|
||||
// a local (let) binding:
|
||||
DeclLocal(@Local),
|
||||
@ -450,7 +450,7 @@ pub enum Decl_ {
|
||||
DeclItem(@Item),
|
||||
}
|
||||
|
||||
#[deriving(Clone, PartialEq, TotalEq, Encodable, Decodable, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
|
||||
pub struct Arm {
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub pats: Vec<@Pat>,
|
||||
@ -458,7 +458,7 @@ pub struct Arm {
|
||||
pub body: @Expr,
|
||||
}
|
||||
|
||||
#[deriving(Clone, PartialEq, TotalEq, Encodable, Decodable, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
|
||||
pub struct Field {
|
||||
pub ident: SpannedIdent,
|
||||
pub expr: @Expr,
|
||||
@ -467,26 +467,26 @@ pub struct Field {
|
||||
|
||||
pub type SpannedIdent = Spanned<Ident>;
|
||||
|
||||
#[deriving(Clone, PartialEq, TotalEq, Encodable, Decodable, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
|
||||
pub enum BlockCheckMode {
|
||||
DefaultBlock,
|
||||
UnsafeBlock(UnsafeSource),
|
||||
}
|
||||
|
||||
#[deriving(Clone, PartialEq, TotalEq, Encodable, Decodable, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
|
||||
pub enum UnsafeSource {
|
||||
CompilerGenerated,
|
||||
UserProvided,
|
||||
}
|
||||
|
||||
#[deriving(Clone, PartialEq, TotalEq, Encodable, Decodable, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
|
||||
pub struct Expr {
|
||||
pub id: NodeId,
|
||||
pub node: Expr_,
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
#[deriving(Clone, PartialEq, TotalEq, Encodable, Decodable, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
|
||||
pub enum Expr_ {
|
||||
ExprVstore(@Expr, ExprVstore),
|
||||
// First expr is the place; second expr is the value.
|
||||
@ -555,7 +555,7 @@ pub enum Expr_ {
|
||||
// else knows what to do with them, so you'll probably get a syntax
|
||||
// error.
|
||||
//
|
||||
#[deriving(Clone, PartialEq, TotalEq, Encodable, Decodable, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
|
||||
#[doc="For macro invocations; parsing is delegated to the macro"]
|
||||
pub enum TokenTree {
|
||||
// a single token
|
||||
@ -631,7 +631,7 @@ pub enum TokenTree {
|
||||
//
|
||||
pub type Matcher = Spanned<Matcher_>;
|
||||
|
||||
#[deriving(Clone, PartialEq, TotalEq, Encodable, Decodable, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
|
||||
pub enum Matcher_ {
|
||||
// match one token
|
||||
MatchTok(::parse::token::Token),
|
||||
@ -648,12 +648,12 @@ pub type Mac = Spanned<Mac_>;
|
||||
// is being invoked, and the vector of token-trees contains the source
|
||||
// of the macro invocation.
|
||||
// There's only one flavor, now, so this could presumably be simplified.
|
||||
#[deriving(Clone, PartialEq, TotalEq, Encodable, Decodable, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
|
||||
pub enum Mac_ {
|
||||
MacInvocTT(Path, Vec<TokenTree> , SyntaxContext), // new macro-invocation
|
||||
}
|
||||
|
||||
#[deriving(Clone, PartialEq, TotalEq, Encodable, Decodable, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
|
||||
pub enum StrStyle {
|
||||
CookedStr,
|
||||
RawStr(uint)
|
||||
@ -661,7 +661,7 @@ pub enum StrStyle {
|
||||
|
||||
pub type Lit = Spanned<Lit_>;
|
||||
|
||||
#[deriving(Clone, PartialEq, TotalEq, Encodable, Decodable, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
|
||||
pub enum Lit_ {
|
||||
LitStr(InternedString, StrStyle),
|
||||
LitBinary(Rc<Vec<u8> >),
|
||||
@ -677,20 +677,20 @@ pub enum Lit_ {
|
||||
|
||||
// NB: If you change this, you'll probably want to change the corresponding
|
||||
// type structure in middle/ty.rs as well.
|
||||
#[deriving(Clone, PartialEq, TotalEq, Encodable, Decodable, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
|
||||
pub struct MutTy {
|
||||
pub ty: P<Ty>,
|
||||
pub mutbl: Mutability,
|
||||
}
|
||||
|
||||
#[deriving(PartialEq, TotalEq, Encodable, Decodable, Hash)]
|
||||
#[deriving(PartialEq, Eq, Encodable, Decodable, Hash)]
|
||||
pub struct TypeField {
|
||||
pub ident: Ident,
|
||||
pub mt: MutTy,
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
#[deriving(Clone, PartialEq, TotalEq, Encodable, Decodable, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
|
||||
pub struct TypeMethod {
|
||||
pub ident: Ident,
|
||||
pub attrs: Vec<Attribute>,
|
||||
@ -706,13 +706,13 @@ pub struct TypeMethod {
|
||||
// A trait method is either required (meaning it doesn't have an
|
||||
// implementation, just a signature) or provided (meaning it has a default
|
||||
// implementation).
|
||||
#[deriving(Clone, PartialEq, TotalEq, Encodable, Decodable, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
|
||||
pub enum TraitMethod {
|
||||
Required(TypeMethod),
|
||||
Provided(@Method),
|
||||
}
|
||||
|
||||
#[deriving(Clone, PartialEq, TotalEq, Encodable, Decodable, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
|
||||
pub enum IntTy {
|
||||
TyI,
|
||||
TyI8,
|
||||
@ -728,7 +728,7 @@ impl fmt::Show for IntTy {
|
||||
}
|
||||
}
|
||||
|
||||
#[deriving(Clone, PartialEq, TotalEq, Encodable, Decodable, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
|
||||
pub enum UintTy {
|
||||
TyU,
|
||||
TyU8,
|
||||
@ -744,7 +744,7 @@ impl fmt::Show for UintTy {
|
||||
}
|
||||
}
|
||||
|
||||
#[deriving(Clone, PartialEq, TotalEq, Encodable, Decodable, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
|
||||
pub enum FloatTy {
|
||||
TyF32,
|
||||
TyF64,
|
||||
@ -758,7 +758,7 @@ impl fmt::Show for FloatTy {
|
||||
}
|
||||
|
||||
// NB PartialEq method appears below.
|
||||
#[deriving(Clone, PartialEq, TotalEq, Encodable, Decodable, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
|
||||
pub struct Ty {
|
||||
pub id: NodeId,
|
||||
pub node: Ty_,
|
||||
@ -766,7 +766,7 @@ pub struct Ty {
|
||||
}
|
||||
|
||||
// Not represented directly in the AST, referred to by name through a ty_path.
|
||||
#[deriving(Clone, PartialEq, TotalEq, Encodable, Decodable, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
|
||||
pub enum PrimTy {
|
||||
TyInt(IntTy),
|
||||
TyUint(UintTy),
|
||||
@ -776,7 +776,7 @@ pub enum PrimTy {
|
||||
TyChar
|
||||
}
|
||||
|
||||
#[deriving(Clone, PartialEq, TotalEq, Encodable, Decodable, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
|
||||
pub enum Onceness {
|
||||
Once,
|
||||
Many
|
||||
@ -791,7 +791,7 @@ impl fmt::Show for Onceness {
|
||||
}
|
||||
}
|
||||
|
||||
#[deriving(PartialEq, TotalEq, Encodable, Decodable, Hash)]
|
||||
#[deriving(PartialEq, Eq, Encodable, Decodable, Hash)]
|
||||
pub struct ClosureTy {
|
||||
pub lifetimes: Vec<Lifetime>,
|
||||
pub fn_style: FnStyle,
|
||||
@ -804,7 +804,7 @@ pub struct ClosureTy {
|
||||
pub bounds: Option<OwnedSlice<TyParamBound>>,
|
||||
}
|
||||
|
||||
#[deriving(PartialEq, TotalEq, Encodable, Decodable, Hash)]
|
||||
#[deriving(PartialEq, Eq, Encodable, Decodable, Hash)]
|
||||
pub struct BareFnTy {
|
||||
pub fn_style: FnStyle,
|
||||
pub abi: Abi,
|
||||
@ -812,7 +812,7 @@ pub struct BareFnTy {
|
||||
pub decl: P<FnDecl>
|
||||
}
|
||||
|
||||
#[deriving(Clone, PartialEq, TotalEq, Encodable, Decodable, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
|
||||
pub enum Ty_ {
|
||||
TyNil,
|
||||
TyBot, /* bottom type */
|
||||
@ -833,13 +833,13 @@ pub enum Ty_ {
|
||||
TyInfer,
|
||||
}
|
||||
|
||||
#[deriving(Clone, PartialEq, TotalEq, Encodable, Decodable, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
|
||||
pub enum AsmDialect {
|
||||
AsmAtt,
|
||||
AsmIntel
|
||||
}
|
||||
|
||||
#[deriving(Clone, PartialEq, TotalEq, Encodable, Decodable, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
|
||||
pub struct InlineAsm {
|
||||
pub asm: InternedString,
|
||||
pub asm_str_style: StrStyle,
|
||||
@ -851,7 +851,7 @@ pub struct InlineAsm {
|
||||
pub dialect: AsmDialect
|
||||
}
|
||||
|
||||
#[deriving(Clone, PartialEq, TotalEq, Encodable, Decodable, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
|
||||
pub struct Arg {
|
||||
pub ty: P<Ty>,
|
||||
pub pat: @Pat,
|
||||
@ -878,7 +878,7 @@ impl Arg {
|
||||
}
|
||||
}
|
||||
|
||||
#[deriving(Clone, PartialEq, TotalEq, Encodable, Decodable, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
|
||||
pub struct FnDecl {
|
||||
pub inputs: Vec<Arg>,
|
||||
pub output: P<Ty>,
|
||||
@ -886,7 +886,7 @@ pub struct FnDecl {
|
||||
pub variadic: bool
|
||||
}
|
||||
|
||||
#[deriving(Clone, PartialEq, TotalEq, Encodable, Decodable, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
|
||||
pub enum FnStyle {
|
||||
UnsafeFn, // declared with "unsafe fn"
|
||||
NormalFn, // declared with "fn"
|
||||
@ -901,14 +901,14 @@ impl fmt::Show for FnStyle {
|
||||
}
|
||||
}
|
||||
|
||||
#[deriving(Clone, PartialEq, TotalEq, Encodable, Decodable, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
|
||||
pub enum RetStyle {
|
||||
NoReturn, // functions with return type _|_ that always
|
||||
// raise an error or exit (i.e. never return to the caller)
|
||||
Return, // everything else
|
||||
}
|
||||
|
||||
#[deriving(Clone, PartialEq, TotalEq, Encodable, Decodable, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
|
||||
pub enum ExplicitSelf_ {
|
||||
SelfStatic, // no self
|
||||
SelfValue, // `self`
|
||||
@ -918,7 +918,7 @@ pub enum ExplicitSelf_ {
|
||||
|
||||
pub type ExplicitSelf = Spanned<ExplicitSelf_>;
|
||||
|
||||
#[deriving(PartialEq, TotalEq, Encodable, Decodable, Hash)]
|
||||
#[deriving(PartialEq, Eq, Encodable, Decodable, Hash)]
|
||||
pub struct Method {
|
||||
pub ident: Ident,
|
||||
pub attrs: Vec<Attribute>,
|
||||
@ -932,7 +932,7 @@ pub struct Method {
|
||||
pub vis: Visibility,
|
||||
}
|
||||
|
||||
#[deriving(Clone, PartialEq, TotalEq, Encodable, Decodable, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
|
||||
pub struct Mod {
|
||||
/// A span from the first token past `{` to the last token until `}`.
|
||||
/// For `mod foo;`, the inner span ranges from the first token
|
||||
@ -942,31 +942,31 @@ pub struct Mod {
|
||||
pub items: Vec<@Item>,
|
||||
}
|
||||
|
||||
#[deriving(Clone, PartialEq, TotalEq, Encodable, Decodable, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
|
||||
pub struct ForeignMod {
|
||||
pub abi: Abi,
|
||||
pub view_items: Vec<ViewItem>,
|
||||
pub items: Vec<@ForeignItem>,
|
||||
}
|
||||
|
||||
#[deriving(Clone, PartialEq, TotalEq, Encodable, Decodable, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
|
||||
pub struct VariantArg {
|
||||
pub ty: P<Ty>,
|
||||
pub id: NodeId,
|
||||
}
|
||||
|
||||
#[deriving(Clone, PartialEq, TotalEq, Encodable, Decodable, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
|
||||
pub enum VariantKind {
|
||||
TupleVariantKind(Vec<VariantArg>),
|
||||
StructVariantKind(@StructDef),
|
||||
}
|
||||
|
||||
#[deriving(Clone, PartialEq, TotalEq, Encodable, Decodable, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
|
||||
pub struct EnumDef {
|
||||
pub variants: Vec<P<Variant>>,
|
||||
}
|
||||
|
||||
#[deriving(Clone, PartialEq, TotalEq, Encodable, Decodable, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
|
||||
pub struct Variant_ {
|
||||
pub name: Ident,
|
||||
pub attrs: Vec<Attribute>,
|
||||
@ -978,7 +978,7 @@ pub struct Variant_ {
|
||||
|
||||
pub type Variant = Spanned<Variant_>;
|
||||
|
||||
#[deriving(Clone, PartialEq, TotalEq, Encodable, Decodable, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
|
||||
pub struct PathListIdent_ {
|
||||
pub name: Ident,
|
||||
pub id: NodeId,
|
||||
@ -988,7 +988,7 @@ pub type PathListIdent = Spanned<PathListIdent_>;
|
||||
|
||||
pub type ViewPath = Spanned<ViewPath_>;
|
||||
|
||||
#[deriving(PartialEq, TotalEq, Encodable, Decodable, Hash)]
|
||||
#[deriving(PartialEq, Eq, Encodable, Decodable, Hash)]
|
||||
pub enum ViewPath_ {
|
||||
|
||||
// quux = foo::bar::baz
|
||||
@ -1005,7 +1005,7 @@ pub enum ViewPath_ {
|
||||
ViewPathList(Path, Vec<PathListIdent> , NodeId)
|
||||
}
|
||||
|
||||
#[deriving(Clone, PartialEq, TotalEq, Encodable, Decodable, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
|
||||
pub struct ViewItem {
|
||||
pub node: ViewItem_,
|
||||
pub attrs: Vec<Attribute>,
|
||||
@ -1013,7 +1013,7 @@ pub struct ViewItem {
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
#[deriving(Clone, PartialEq, TotalEq, Encodable, Decodable, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
|
||||
pub enum ViewItem_ {
|
||||
// ident: name used to refer to this crate in the code
|
||||
// optional (InternedString,StrStyle): if present, this is a location
|
||||
@ -1029,17 +1029,17 @@ pub type Attribute = Spanned<Attribute_>;
|
||||
// Distinguishes between Attributes that decorate items and Attributes that
|
||||
// are contained as statements within items. These two cases need to be
|
||||
// distinguished for pretty-printing.
|
||||
#[deriving(Clone, PartialEq, TotalEq, Encodable, Decodable, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
|
||||
pub enum AttrStyle {
|
||||
AttrOuter,
|
||||
AttrInner,
|
||||
}
|
||||
|
||||
#[deriving(Clone, PartialEq, TotalEq, Encodable, Decodable, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
|
||||
pub struct AttrId(pub uint);
|
||||
|
||||
// doc-comments are promoted to attributes that have is_sugared_doc = true
|
||||
#[deriving(Clone, PartialEq, TotalEq, Encodable, Decodable, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
|
||||
pub struct Attribute_ {
|
||||
pub id: AttrId,
|
||||
pub style: AttrStyle,
|
||||
@ -1054,13 +1054,13 @@ pub struct Attribute_ {
|
||||
If this impl is an ItemImpl, the impl_id is redundant (it could be the
|
||||
same as the impl's node id).
|
||||
*/
|
||||
#[deriving(Clone, PartialEq, TotalEq, Encodable, Decodable, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
|
||||
pub struct TraitRef {
|
||||
pub path: Path,
|
||||
pub ref_id: NodeId,
|
||||
}
|
||||
|
||||
#[deriving(Clone, PartialEq, TotalEq, Encodable, Decodable, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
|
||||
pub enum Visibility {
|
||||
Public,
|
||||
Inherited,
|
||||
@ -1075,13 +1075,13 @@ impl Visibility {
|
||||
}
|
||||
}
|
||||
|
||||
#[deriving(Clone, PartialEq, TotalEq, Encodable, Decodable, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
|
||||
pub enum Sized {
|
||||
DynSize,
|
||||
StaticSize,
|
||||
}
|
||||
|
||||
#[deriving(Clone, PartialEq, TotalEq, Encodable, Decodable, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
|
||||
pub struct StructField_ {
|
||||
pub kind: StructFieldKind,
|
||||
pub id: NodeId,
|
||||
@ -1091,7 +1091,7 @@ pub struct StructField_ {
|
||||
|
||||
pub type StructField = Spanned<StructField_>;
|
||||
|
||||
#[deriving(Clone, PartialEq, TotalEq, Encodable, Decodable, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
|
||||
pub enum StructFieldKind {
|
||||
NamedField(Ident, Visibility),
|
||||
UnnamedField(Visibility), // element of a tuple-like struct
|
||||
@ -1106,7 +1106,7 @@ impl StructFieldKind {
|
||||
}
|
||||
}
|
||||
|
||||
#[deriving(PartialEq, TotalEq, Encodable, Decodable, Hash)]
|
||||
#[deriving(PartialEq, Eq, Encodable, Decodable, Hash)]
|
||||
pub struct StructDef {
|
||||
pub fields: Vec<StructField>, /* fields, not including ctor */
|
||||
/* ID of the constructor. This is only used for tuple- or enum-like
|
||||
@ -1120,7 +1120,7 @@ pub struct StructDef {
|
||||
FIXME (#3300): Should allow items to be anonymous. Right now
|
||||
we just use dummy names for anon items.
|
||||
*/
|
||||
#[deriving(Clone, PartialEq, TotalEq, Encodable, Decodable, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
|
||||
pub struct Item {
|
||||
pub ident: Ident,
|
||||
pub attrs: Vec<Attribute>,
|
||||
@ -1130,7 +1130,7 @@ pub struct Item {
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
#[deriving(Clone, PartialEq, TotalEq, Encodable, Decodable, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
|
||||
pub enum Item_ {
|
||||
ItemStatic(P<Ty>, Mutability, @Expr),
|
||||
ItemFn(P<FnDecl>, FnStyle, Abi, Generics, P<Block>),
|
||||
@ -1148,7 +1148,7 @@ pub enum Item_ {
|
||||
ItemMac(Mac),
|
||||
}
|
||||
|
||||
#[deriving(PartialEq, TotalEq, Encodable, Decodable, Hash)]
|
||||
#[deriving(PartialEq, Eq, Encodable, Decodable, Hash)]
|
||||
pub struct ForeignItem {
|
||||
pub ident: Ident,
|
||||
pub attrs: Vec<Attribute>,
|
||||
@ -1158,7 +1158,7 @@ pub struct ForeignItem {
|
||||
pub vis: Visibility,
|
||||
}
|
||||
|
||||
#[deriving(PartialEq, TotalEq, Encodable, Decodable, Hash)]
|
||||
#[deriving(PartialEq, Eq, Encodable, Decodable, Hash)]
|
||||
pub enum ForeignItem_ {
|
||||
ForeignItemFn(P<FnDecl>, Generics),
|
||||
ForeignItemStatic(P<Ty>, /* is_mutbl */ bool),
|
||||
@ -1167,7 +1167,7 @@ pub enum ForeignItem_ {
|
||||
// The data we save and restore about an inlined item or method. This is not
|
||||
// part of the AST that we parse from a file, but it becomes part of the tree
|
||||
// that we trans.
|
||||
#[deriving(PartialEq, TotalEq, Encodable, Decodable, Hash)]
|
||||
#[deriving(PartialEq, Eq, Encodable, Decodable, Hash)]
|
||||
pub enum InlinedItem {
|
||||
IIItem(@Item),
|
||||
IIMethod(DefId /* impl id */, bool /* is provided */, @Method),
|
||||
|
@ -33,7 +33,7 @@ pub trait Pos {
|
||||
|
||||
/// A byte offset. Keep this small (currently 32-bits), as AST contains
|
||||
/// a lot of them.
|
||||
#[deriving(Clone, PartialEq, TotalEq, Hash, PartialOrd, Show)]
|
||||
#[deriving(Clone, PartialEq, Eq, Hash, PartialOrd, Show)]
|
||||
pub struct BytePos(pub u32);
|
||||
|
||||
/// A character offset. Because of multibyte utf8 characters, a byte offset
|
||||
@ -96,7 +96,7 @@ pub struct Span {
|
||||
|
||||
pub static DUMMY_SP: Span = Span { lo: BytePos(0), hi: BytePos(0), expn_info: None };
|
||||
|
||||
#[deriving(Clone, PartialEq, TotalEq, Encodable, Decodable, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
|
||||
pub struct Spanned<T> {
|
||||
pub node: T,
|
||||
pub span: Span,
|
||||
@ -109,7 +109,7 @@ impl PartialEq for Span {
|
||||
fn ne(&self, other: &Span) -> bool { !(*self).eq(other) }
|
||||
}
|
||||
|
||||
impl TotalEq for Span {}
|
||||
impl Eq for Span {}
|
||||
|
||||
impl<S:Encoder<E>, E> Encodable<S, E> for Span {
|
||||
/* Note #1972 -- spans are encoded but not decoded */
|
||||
|
@ -28,7 +28,7 @@ Supported features (fairly exhaustive):
|
||||
moment. (`TraitDef.additional_bounds`)
|
||||
|
||||
Unsupported: FIXME #6257: calling methods on reference fields,
|
||||
e.g. deriving TotalEq/TotalOrd/Clone don't work on `struct A(&int)`,
|
||||
e.g. deriving Eq/Ord/Clone don't work on `struct A(&int)`,
|
||||
because of how the auto-dereferencing happens.
|
||||
|
||||
The most important thing for implementers is the `Substructure` and
|
||||
|
@ -79,9 +79,9 @@ pub fn expand_meta_deriving(cx: &mut ExtCtxt,
|
||||
|
||||
// NOTE: after a stage0 snap this needs treatment
|
||||
"PartialEq" => expand!(eq::expand_deriving_eq),
|
||||
"Eq" | "TotalEq" => expand!(totaleq::expand_deriving_totaleq),
|
||||
"Eq" => expand!(totaleq::expand_deriving_totaleq),
|
||||
"PartialOrd" => expand!(ord::expand_deriving_ord),
|
||||
"Ord" | "TotalOrd" => expand!(totalord::expand_deriving_totalord),
|
||||
"Ord" => expand!(totalord::expand_deriving_totalord),
|
||||
|
||||
"Rand" => expand!(rand::expand_deriving_rand),
|
||||
|
||||
|
@ -119,7 +119,7 @@ impl<T: PartialEq> PartialEq for OwnedSlice<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: TotalEq> TotalEq for OwnedSlice<T> {}
|
||||
impl<T: Eq> Eq for OwnedSlice<T> {}
|
||||
|
||||
impl<T> Container for OwnedSlice<T> {
|
||||
fn len(&self) -> uint { self.len }
|
||||
|
@ -23,7 +23,7 @@ use parse::parser;
|
||||
use parse::token;
|
||||
|
||||
/// The specific types of unsupported syntax
|
||||
#[deriving(PartialEq, TotalEq, Hash)]
|
||||
#[deriving(PartialEq, Eq, Hash)]
|
||||
pub enum ObsoleteSyntax {
|
||||
ObsoleteOwnedType,
|
||||
ObsoleteOwnedExpr,
|
||||
|
@ -24,7 +24,7 @@ use std::rc::Rc;
|
||||
use std::string::String;
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
#[deriving(Clone, Encodable, Decodable, PartialEq, TotalEq, Hash, Show)]
|
||||
#[deriving(Clone, Encodable, Decodable, PartialEq, Eq, Hash, Show)]
|
||||
pub enum BinOp {
|
||||
PLUS,
|
||||
MINUS,
|
||||
@ -39,7 +39,7 @@ pub enum BinOp {
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
#[deriving(Clone, Encodable, Decodable, PartialEq, TotalEq, Hash, Show)]
|
||||
#[deriving(Clone, Encodable, Decodable, PartialEq, Eq, Hash, Show)]
|
||||
pub enum Token {
|
||||
/* Expression-operator symbols. */
|
||||
EQ,
|
||||
@ -102,7 +102,7 @@ pub enum Token {
|
||||
EOF,
|
||||
}
|
||||
|
||||
#[deriving(Clone, Encodable, Decodable, PartialEq, TotalEq, Hash)]
|
||||
#[deriving(Clone, Encodable, Decodable, PartialEq, Eq, Hash)]
|
||||
/// For interpolation during macro expansion.
|
||||
pub enum Nonterminal {
|
||||
NtItem(@ast::Item),
|
||||
@ -552,7 +552,7 @@ pub fn get_ident_interner() -> Rc<IdentInterner> {
|
||||
/// destroyed. In particular, they must not access string contents. This can
|
||||
/// be fixed in the future by just leaking all strings until task death
|
||||
/// somehow.
|
||||
#[deriving(Clone, PartialEq, Hash, PartialOrd, TotalEq, TotalOrd)]
|
||||
#[deriving(Clone, PartialEq, Hash, PartialOrd, Eq, Ord)]
|
||||
pub struct InternedString {
|
||||
string: RcStr,
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ pub struct Interner<T> {
|
||||
}
|
||||
|
||||
// when traits can extend traits, we should extend index<Name,T> to get []
|
||||
impl<T: TotalEq + Hash + Clone + 'static> Interner<T> {
|
||||
impl<T: Eq + Hash + Clone + 'static> Interner<T> {
|
||||
pub fn new() -> Interner<T> {
|
||||
Interner {
|
||||
map: RefCell::new(HashMap::new()),
|
||||
@ -95,9 +95,9 @@ pub struct RcStr {
|
||||
string: Rc<String>,
|
||||
}
|
||||
|
||||
impl TotalEq for RcStr {}
|
||||
impl Eq for RcStr {}
|
||||
|
||||
impl TotalOrd for RcStr {
|
||||
impl Ord for RcStr {
|
||||
fn cmp(&self, other: &RcStr) -> Ordering {
|
||||
self.as_slice().cmp(&other.as_slice())
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ pub mod stats;
|
||||
// colons. This way if some test runner wants to arrange the tests
|
||||
// hierarchically it may.
|
||||
|
||||
#[deriving(Clone, PartialEq, TotalEq, Hash)]
|
||||
#[deriving(Clone, PartialEq, Eq, Hash)]
|
||||
pub enum TestName {
|
||||
StaticTestName(&'static str),
|
||||
DynTestName(String)
|
||||
@ -183,7 +183,7 @@ pub struct Bencher {
|
||||
|
||||
// The definition of a single test. A test runner will run a list of
|
||||
// these.
|
||||
#[deriving(Clone, Show, PartialEq, TotalEq, Hash)]
|
||||
#[deriving(Clone, Show, PartialEq, Eq, Hash)]
|
||||
pub struct TestDesc {
|
||||
pub name: TestName,
|
||||
pub ignore: bool,
|
||||
|
@ -441,7 +441,7 @@ pub fn write_boxplot<T: Float + Show + FromPrimitive>(
|
||||
|
||||
/// Returns a HashMap with the number of occurrences of every element in the
|
||||
/// sequence that the iterator exposes.
|
||||
pub fn freq_count<T: Iterator<U>, U: TotalEq+Hash>(mut iter: T) -> hashmap::HashMap<U, uint> {
|
||||
pub fn freq_count<T: Iterator<U>, U: Eq+Hash>(mut iter: T) -> hashmap::HashMap<U, uint> {
|
||||
let mut map: hashmap::HashMap<U,uint> = hashmap::HashMap::new();
|
||||
for elem in iter {
|
||||
map.insert_or_update_with(elem, 1, |_, count| *count += 1);
|
||||
|
@ -74,7 +74,7 @@ mod imp {
|
||||
}
|
||||
|
||||
/// A record specifying a time value in seconds and nanoseconds.
|
||||
#[deriving(Clone, PartialEq, TotalEq, PartialOrd, TotalOrd, Encodable, Decodable, Show)]
|
||||
#[deriving(Clone, PartialEq, Eq, PartialOrd, Ord, Encodable, Decodable, Show)]
|
||||
pub struct Timespec { pub sec: i64, pub nsec: i32 }
|
||||
/*
|
||||
* Timespec assumes that pre-epoch Timespecs have negative sec and positive
|
||||
|
@ -48,7 +48,7 @@ use std::uint;
|
||||
/// fragment: Some("quz".to_string()) };
|
||||
/// // https://username@example.com:8080/foo/bar?baz=qux#quz
|
||||
/// ```
|
||||
#[deriving(Clone, PartialEq, TotalEq)]
|
||||
#[deriving(Clone, PartialEq, Eq)]
|
||||
pub struct Url {
|
||||
/// The scheme part of a URL, such as `https` in the above example.
|
||||
pub scheme: String,
|
||||
@ -81,7 +81,7 @@ pub struct Path {
|
||||
}
|
||||
|
||||
/// An optional subcomponent of a URI authority component.
|
||||
#[deriving(Clone, PartialEq, TotalEq)]
|
||||
#[deriving(Clone, PartialEq, Eq)]
|
||||
pub struct UserInfo {
|
||||
/// The user name.
|
||||
pub user: String,
|
||||
|
@ -487,7 +487,7 @@ impl PartialEq for Uuid {
|
||||
}
|
||||
}
|
||||
|
||||
impl TotalEq for Uuid {}
|
||||
impl Eq for Uuid {}
|
||||
|
||||
// FIXME #9845: Test these more thoroughly
|
||||
impl<T: Encoder<E>, E> Encodable<T, E> for Uuid {
|
||||
|
@ -1,3 +1,11 @@
|
||||
S 2014-05-30 60a43f9
|
||||
freebsd-x86_64 59067eb9e89bde3e20a1078104f4b1105e4b56fc
|
||||
linux-i386 c1a81811e8e104c91c35d94a140e3cf8463c7655
|
||||
linux-x86_64 5c7167a2f964118103af5735a9215e8421803406
|
||||
macos-i386 872b9818badefda412c7513b93742369f969094d
|
||||
macos-x86_64 78c0f2ead6287c433d0cd18e1860404526ba5049
|
||||
winnt-i386 63ca814f86493a8f06ab616b5e31d49a19bec1b2
|
||||
|
||||
S 2014-05-29 50b8528
|
||||
freebsd-x86_64 cfa0dcc98a57f03a53bb53df6fd5db02143e2bee
|
||||
linux-i386 baf7c6ab5792f3d560a0f2adc94d7ff96d0cab3d
|
||||
|
@ -30,7 +30,7 @@ static OCCURRENCES: [&'static str, ..5] = [
|
||||
|
||||
// Code implementation
|
||||
|
||||
#[deriving(PartialEq, PartialOrd, TotalOrd, TotalEq)]
|
||||
#[deriving(PartialEq, PartialOrd, Ord, Eq)]
|
||||
struct Code(u64);
|
||||
|
||||
impl Code {
|
||||
|
@ -16,7 +16,7 @@ extern crate rand;
|
||||
#[deriving(PartialEq)]
|
||||
struct Error;
|
||||
|
||||
#[deriving(TotalEq,PartialEq)]
|
||||
#[deriving(Eq,PartialEq)]
|
||||
enum Enum {
|
||||
A {
|
||||
x: Error //~ ERROR
|
||||
|
@ -16,7 +16,7 @@ extern crate rand;
|
||||
#[deriving(PartialEq)]
|
||||
struct Error;
|
||||
|
||||
#[deriving(TotalEq,PartialEq)]
|
||||
#[deriving(Eq,PartialEq)]
|
||||
enum Enum {
|
||||
A(
|
||||
Error //~ ERROR
|
||||
|
@ -16,7 +16,7 @@ extern crate rand;
|
||||
#[deriving(PartialEq)]
|
||||
struct Error;
|
||||
|
||||
#[deriving(TotalEq,PartialEq)]
|
||||
#[deriving(Eq,PartialEq)]
|
||||
struct Struct {
|
||||
x: Error //~ ERROR
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ extern crate rand;
|
||||
#[deriving(PartialEq)]
|
||||
struct Error;
|
||||
|
||||
#[deriving(TotalEq,PartialEq)]
|
||||
#[deriving(Eq,PartialEq)]
|
||||
struct Struct(
|
||||
Error //~ ERROR
|
||||
);
|
||||
|
@ -13,10 +13,10 @@
|
||||
#![feature(struct_variant)]
|
||||
extern crate rand;
|
||||
|
||||
#[deriving(TotalEq,PartialOrd,PartialEq)]
|
||||
#[deriving(Eq,PartialOrd,PartialEq)]
|
||||
struct Error;
|
||||
|
||||
#[deriving(TotalOrd,TotalEq,PartialOrd,PartialEq)]
|
||||
#[deriving(Ord,Eq,PartialOrd,PartialEq)]
|
||||
enum Enum {
|
||||
A {
|
||||
x: Error //~ ERROR
|
||||
|
@ -13,10 +13,10 @@
|
||||
#![feature(struct_variant)]
|
||||
extern crate rand;
|
||||
|
||||
#[deriving(TotalEq,PartialOrd,PartialEq)]
|
||||
#[deriving(Eq,PartialOrd,PartialEq)]
|
||||
struct Error;
|
||||
|
||||
#[deriving(TotalOrd,TotalEq,PartialOrd,PartialEq)]
|
||||
#[deriving(Ord,Eq,PartialOrd,PartialEq)]
|
||||
enum Enum {
|
||||
A(
|
||||
Error //~ ERROR
|
||||
|
@ -13,10 +13,10 @@
|
||||
#![feature(struct_variant)]
|
||||
extern crate rand;
|
||||
|
||||
#[deriving(TotalEq,PartialOrd,PartialEq)]
|
||||
#[deriving(Eq,PartialOrd,PartialEq)]
|
||||
struct Error;
|
||||
|
||||
#[deriving(TotalOrd,TotalEq,PartialOrd,PartialEq)]
|
||||
#[deriving(Ord,Eq,PartialOrd,PartialEq)]
|
||||
struct Struct {
|
||||
x: Error //~ ERROR
|
||||
}
|
||||
|
@ -13,10 +13,10 @@
|
||||
#![feature(struct_variant)]
|
||||
extern crate rand;
|
||||
|
||||
#[deriving(TotalEq,PartialOrd,PartialEq)]
|
||||
#[deriving(Eq,PartialOrd,PartialEq)]
|
||||
struct Error;
|
||||
|
||||
#[deriving(TotalOrd,TotalEq,PartialOrd,PartialEq)]
|
||||
#[deriving(Ord,Eq,PartialOrd,PartialEq)]
|
||||
struct Struct(
|
||||
Error //~ ERROR
|
||||
);
|
||||
|
@ -8,7 +8,7 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#[deriving(PartialEq, TotalEq, PartialOrd, TotalOrd)]
|
||||
#[deriving(PartialEq, Eq, PartialOrd, Ord)]
|
||||
enum E<T> {
|
||||
E0,
|
||||
E1(T),
|
||||
@ -22,7 +22,7 @@ pub fn main() {
|
||||
let e21 = E2(1, 1);
|
||||
let e22 = E2(1, 2);
|
||||
|
||||
// in order for both PartialOrd and TotalOrd
|
||||
// in order for both PartialOrd and Ord
|
||||
let es = [e0, e11, e12, e21, e22];
|
||||
|
||||
for (i, e1) in es.iter().enumerate() {
|
||||
@ -46,7 +46,7 @@ pub fn main() {
|
||||
assert_eq!(*e1 <= *e2, le);
|
||||
assert_eq!(*e1 >= *e2, ge);
|
||||
|
||||
// TotalOrd
|
||||
// Ord
|
||||
assert_eq!(e1.cmp(e2), ord);
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
#![feature(struct_variant)]
|
||||
|
||||
#[deriving(PartialEq, TotalEq, PartialOrd, TotalOrd)]
|
||||
#[deriving(PartialEq, Eq, PartialOrd, Ord)]
|
||||
enum ES<T> {
|
||||
ES1 { x: T },
|
||||
ES2 { x: T, y: T }
|
||||
@ -20,7 +20,7 @@ enum ES<T> {
|
||||
pub fn main() {
|
||||
let (es11, es12, es21, es22) = (ES1 {x: 1}, ES1 {x: 2}, ES2 {x: 1, y: 1}, ES2 {x: 1, y: 2});
|
||||
|
||||
// in order for both PartialOrd and TotalOrd
|
||||
// in order for both PartialOrd and Ord
|
||||
let ess = [es11, es12, es21, es22];
|
||||
|
||||
for (i, es1) in ess.iter().enumerate() {
|
||||
@ -42,7 +42,7 @@ pub fn main() {
|
||||
assert_eq!(*es1 <= *es2, le);
|
||||
assert_eq!(*es1 >= *es2, ge);
|
||||
|
||||
// TotalOrd
|
||||
// Ord
|
||||
assert_eq!(es1.cmp(es2), ord);
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,7 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#[deriving(PartialEq, TotalEq, PartialOrd, TotalOrd)]
|
||||
#[deriving(PartialEq, Eq, PartialOrd, Ord)]
|
||||
struct S<T> {
|
||||
x: T,
|
||||
y: T
|
||||
@ -18,7 +18,7 @@ pub fn main() {
|
||||
let s1 = S {x: 1, y: 1};
|
||||
let s2 = S {x: 1, y: 2};
|
||||
|
||||
// in order for both PartialOrd and TotalOrd
|
||||
// in order for both PartialOrd and Ord
|
||||
let ss = [s1, s2];
|
||||
|
||||
for (i, s1) in ss.iter().enumerate() {
|
||||
@ -42,7 +42,7 @@ pub fn main() {
|
||||
assert_eq!(*s1 <= *s2, le);
|
||||
assert_eq!(*s1 >= *s2, ge);
|
||||
|
||||
// TotalOrd
|
||||
// Ord
|
||||
assert_eq!(s1.cmp(s2), ord);
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,7 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#[deriving(PartialEq, TotalEq, PartialOrd, TotalOrd)]
|
||||
#[deriving(PartialEq, Eq, PartialOrd, Ord)]
|
||||
struct TS<T>(T,T);
|
||||
|
||||
|
||||
@ -16,7 +16,7 @@ pub fn main() {
|
||||
let ts1 = TS(1, 1);
|
||||
let ts2 = TS(1, 2);
|
||||
|
||||
// in order for both PartialOrd and TotalOrd
|
||||
// in order for both PartialOrd and Ord
|
||||
let tss = [ts1, ts2];
|
||||
|
||||
for (i, ts1) in tss.iter().enumerate() {
|
||||
@ -40,7 +40,7 @@ pub fn main() {
|
||||
assert_eq!(*ts1 <= *ts2, le);
|
||||
assert_eq!(*ts1 >= *ts2, ge);
|
||||
|
||||
// TotalOrd
|
||||
// Ord
|
||||
assert_eq!(ts1.cmp(ts2), ord);
|
||||
}
|
||||
}
|
||||
|
@ -21,13 +21,13 @@ impl PartialOrd for FailCmp {
|
||||
fn lt(&self, _: &FailCmp) -> bool { fail!("lt") }
|
||||
}
|
||||
|
||||
impl TotalEq for FailCmp {}
|
||||
impl Eq for FailCmp {}
|
||||
|
||||
impl TotalOrd for FailCmp {
|
||||
impl Ord for FailCmp {
|
||||
fn cmp(&self, _: &FailCmp) -> Ordering { fail!("cmp") }
|
||||
}
|
||||
|
||||
#[deriving(PartialEq,PartialOrd,TotalEq,TotalOrd)]
|
||||
#[deriving(PartialEq,PartialOrd,Eq,Ord)]
|
||||
struct ShortCircuit {
|
||||
x: int,
|
||||
y: FailCmp
|
||||
|
@ -15,21 +15,21 @@ mod submod {
|
||||
// if any of these are implemented without global calls for any
|
||||
// function calls, then being in a submodule will (correctly)
|
||||
// cause errors about unrecognised module `std` (or `extra`)
|
||||
#[deriving(PartialEq, PartialOrd, TotalEq, TotalOrd,
|
||||
#[deriving(PartialEq, PartialOrd, Eq, Ord,
|
||||
Hash,
|
||||
Clone,
|
||||
Show, Rand,
|
||||
Encodable, Decodable)]
|
||||
enum A { A1(uint), A2(int) }
|
||||
|
||||
#[deriving(PartialEq, PartialOrd, TotalEq, TotalOrd,
|
||||
#[deriving(PartialEq, PartialOrd, Eq, Ord,
|
||||
Hash,
|
||||
Clone,
|
||||
Show, Rand,
|
||||
Encodable, Decodable)]
|
||||
struct B { x: uint, y: int }
|
||||
|
||||
#[deriving(PartialEq, PartialOrd, TotalEq, TotalOrd,
|
||||
#[deriving(PartialEq, PartialOrd, Eq, Ord,
|
||||
Hash,
|
||||
Clone,
|
||||
Show, Rand,
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
use std::cmp::{Less,Equal,Greater};
|
||||
|
||||
#[deriving(TotalEq,TotalOrd)]
|
||||
#[deriving(Eq,Ord)]
|
||||
struct A<'a> {
|
||||
x: &'a int
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ extern crate collections;
|
||||
|
||||
use collections::HashSet;
|
||||
|
||||
#[deriving(PartialEq, TotalEq, Hash)]
|
||||
#[deriving(PartialEq, Eq, Hash)]
|
||||
struct XYZ {
|
||||
x: int,
|
||||
y: int,
|
||||
|
@ -40,7 +40,7 @@ impl<'tcx> PartialEq for TypeStructure<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> TotalEq for TypeStructure<'tcx> {}
|
||||
impl<'tcx> Eq for TypeStructure<'tcx> {}
|
||||
|
||||
struct TypeContext<'tcx, 'ast> {
|
||||
ty_arena: &'tcx Arena,
|
||||
@ -86,7 +86,7 @@ impl<'tcx,'ast> TypeContext<'tcx, 'ast> {
|
||||
}
|
||||
}
|
||||
|
||||
#[deriving(PartialEq, TotalEq, Hash)]
|
||||
#[deriving(PartialEq, Eq, Hash)]
|
||||
struct NodeId {
|
||||
id: uint
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ static MAX_LEN: uint = 20;
|
||||
static mut drop_counts: [uint, .. MAX_LEN] = [0, .. MAX_LEN];
|
||||
static mut clone_count: uint = 0;
|
||||
|
||||
#[deriving(Rand, PartialEq, PartialOrd, TotalEq, TotalOrd)]
|
||||
#[deriving(Rand, PartialEq, PartialOrd, Eq, Ord)]
|
||||
struct DropCounter { x: uint, clone_num: uint }
|
||||
|
||||
impl Clone for DropCounter {
|
||||
|
Loading…
x
Reference in New Issue
Block a user