about summary refs log tree commit diff
path: root/src/libgraphviz
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2014-07-02 11:08:21 -0700
committerAlex Crichton <alex@alexcrichton.com>2014-07-02 11:08:21 -0700
commitff1dd44b40a7243f43a8d32ba8bd6026197c320b (patch)
tree4460cbf0a917a289d1d3744d9645c5ab131ea9df /src/libgraphviz
parentaa1163b92de7717eb7c5eba002b4012e0574a7fe (diff)
parentca2778ede7c21efc3cf2e4e1152875ec09360770 (diff)
downloadrust-ff1dd44b40a7243f43a8d32ba8bd6026197c320b.tar.gz
rust-ff1dd44b40a7243f43a8d32ba8bd6026197c320b.zip
Merge remote-tracking branch 'origin/master' into 0.11.0-release
Conflicts:
	src/libstd/lib.rs
Diffstat (limited to 'src/libgraphviz')
-rw-r--r--src/libgraphviz/maybe_owned_vec.rs57
1 files changed, 57 insertions, 0 deletions
diff --git a/src/libgraphviz/maybe_owned_vec.rs b/src/libgraphviz/maybe_owned_vec.rs
index a34791f470e..bd19f19cec6 100644
--- a/src/libgraphviz/maybe_owned_vec.rs
+++ b/src/libgraphviz/maybe_owned_vec.rs
@@ -8,8 +8,11 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+use std::collections::Collection;
+use std::default::Default;
 use std::fmt;
 use std::iter::FromIterator;
+use std::path::BytesContainer;
 use std::slice;
 
 // Note 1: It is not clear whether the flexibility of providing both
@@ -61,6 +64,32 @@ impl<'a,T> MaybeOwnedVector<'a,T> {
     }
 }
 
+impl<'a, T: PartialEq> PartialEq for MaybeOwnedVector<'a, T> {
+    fn eq(&self, other: &MaybeOwnedVector<T>) -> bool {
+        self.as_slice() == other.as_slice()
+    }
+}
+
+impl<'a, T: Eq> Eq for MaybeOwnedVector<'a, T> {}
+
+impl<'a, T: PartialOrd> PartialOrd for MaybeOwnedVector<'a, T> {
+    fn partial_cmp(&self, other: &MaybeOwnedVector<T>) -> Option<Ordering> {
+        self.as_slice().partial_cmp(&other.as_slice())
+    }
+}
+
+impl<'a, T: Ord> Ord for MaybeOwnedVector<'a, T> {
+    fn cmp(&self, other: &MaybeOwnedVector<T>) -> Ordering {
+        self.as_slice().cmp(&other.as_slice())
+    }
+}
+
+impl<'a, T: PartialEq, V: Vector<T>> Equiv<V> for MaybeOwnedVector<'a, T> {
+    fn equiv(&self, other: &V) -> bool {
+        self.as_slice() == other.as_slice()
+    }
+}
+
 // The `Vector` trait is provided in the prelude and is implemented on
 // both `&'a [T]` and `Vec<T>`, so it makes sense to try to support it
 // seamlessly.  The other vector related traits from the prelude do
@@ -108,6 +137,34 @@ impl<'a,T:Clone> CloneableVector<T> for MaybeOwnedVector<'a,T> {
     }
 }
 
+impl<'a, T: Clone> Clone for MaybeOwnedVector<'a, T> {
+    fn clone(&self) -> MaybeOwnedVector<'a, T> {
+        match *self {
+            Growable(ref v) => Growable(v.to_owned()),
+            Borrowed(v) => Borrowed(v)
+        }
+    }
+}
+
+
+impl<'a, T> Default for MaybeOwnedVector<'a, T> {
+    fn default() -> MaybeOwnedVector<'a, T> {
+        Growable(Vec::new())
+    }
+}
+
+impl<'a, T> Collection for MaybeOwnedVector<'a, T> {
+    fn len(&self) -> uint {
+        self.as_slice().len()
+    }
+}
+
+impl<'a> BytesContainer for MaybeOwnedVector<'a, u8> {
+    fn container_as_bytes<'a>(&'a self) -> &'a [u8] {
+        self.as_slice()
+    }
+}
+
 impl<'a,T:Clone> MaybeOwnedVector<'a,T> {
     /// Convert `self` into a growable `Vec`, not making a copy if possible.
     pub fn into_vec(self) -> Vec<T> {