about summary refs log tree commit diff
path: root/src/libcore
diff options
context:
space:
mode:
Diffstat (limited to 'src/libcore')
-rw-r--r--src/libcore/char.rs2
-rw-r--r--src/libcore/collections.rs38
-rw-r--r--src/libcore/fmt/float.rs4
-rw-r--r--src/libcore/fmt/mod.rs1
-rw-r--r--src/libcore/fmt/num.rs3
-rw-r--r--src/libcore/lib.rs1
-rw-r--r--src/libcore/prelude.rs1
-rw-r--r--src/libcore/slice.rs46
-rw-r--r--src/libcore/str.rs35
9 files changed, 54 insertions, 77 deletions
diff --git a/src/libcore/char.rs b/src/libcore/char.rs
index 5d9553cbbbd..3b9f8f58a20 100644
--- a/src/libcore/char.rs
+++ b/src/libcore/char.rs
@@ -18,7 +18,7 @@
 use mem::transmute;
 use option::{None, Option, Some};
 use iter::range_step;
-use collections::Collection;
+use slice::ImmutableSlice;
 
 // UTF-8 ranges and tags for encoding characters
 static TAG_CONT: u8    = 0b1000_0000u8;
diff --git a/src/libcore/collections.rs b/src/libcore/collections.rs
deleted file mode 100644
index 7d87e03c134..00000000000
--- a/src/libcore/collections.rs
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! Traits for generic collections
-
-/// A trait to represent the abstract idea of a container. The only concrete
-/// knowledge known is the number of elements contained within.
-pub trait Collection {
-    /// Return the number of elements in the container
-    ///
-    /// # Example
-    ///
-    /// ```
-    /// let a = [1i, 2, 3];
-    /// assert_eq!(a.len(), 3);
-    /// ```
-    fn len(&self) -> uint;
-
-    /// Return true if the container contains no elements
-    ///
-    /// # Example
-    ///
-    /// ```
-    /// let s = String::new();
-    /// assert!(s.is_empty());
-    /// ```
-    #[inline]
-    fn is_empty(&self) -> bool {
-        self.len() == 0
-    }
-}
diff --git a/src/libcore/fmt/float.rs b/src/libcore/fmt/float.rs
index b8a91a912ba..f51d3948757 100644
--- a/src/libcore/fmt/float.rs
+++ b/src/libcore/fmt/float.rs
@@ -11,14 +11,12 @@
 #![allow(missing_docs)]
 
 use char;
-use collections::Collection;
 use fmt;
 use iter::{range, DoubleEndedIterator};
 use num::{Float, FPNaN, FPInfinite, ToPrimitive, Primitive};
 use num::{Zero, One, cast};
 use result::Ok;
-use slice::MutableSlice;
-use slice;
+use slice::{mod, ImmutableSlice, MutableSlice};
 use str::StrSlice;
 
 /// A flag that specifies whether to use exponential (scientific) notation.
diff --git a/src/libcore/fmt/mod.rs b/src/libcore/fmt/mod.rs
index 5000b020985..74b39a7058c 100644
--- a/src/libcore/fmt/mod.rs
+++ b/src/libcore/fmt/mod.rs
@@ -14,7 +14,6 @@
 
 use any;
 use cell::{Cell, Ref, RefMut};
-use collections::Collection;
 use iter::{Iterator, range};
 use kinds::{Copy, Sized};
 use mem;
diff --git a/src/libcore/fmt/num.rs b/src/libcore/fmt/num.rs
index 568528f6ae2..190e1ecea59 100644
--- a/src/libcore/fmt/num.rs
+++ b/src/libcore/fmt/num.rs
@@ -14,11 +14,10 @@
 
 #![allow(unsigned_negation)]
 
-use collections::Collection;
 use fmt;
 use iter::DoubleEndedIterator;
 use num::{Int, cast, zero};
-use slice::{MutableSlice};
+use slice::{ImmutableSlice, MutableSlice};
 
 /// A type that represents a specific radix
 #[doc(hidden)]
diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs
index a7be23e53e0..7c5c54c6d8a 100644
--- a/src/libcore/lib.rs
+++ b/src/libcore/lib.rs
@@ -102,7 +102,6 @@ pub mod ops;
 pub mod cmp;
 pub mod clone;
 pub mod default;
-pub mod collections;
 
 /* Core types and methods on primitives */
 
diff --git a/src/libcore/prelude.rs b/src/libcore/prelude.rs
index 680f91945d1..64917fb2541 100644
--- a/src/libcore/prelude.rs
+++ b/src/libcore/prelude.rs
@@ -50,7 +50,6 @@ pub use char::Char;
 pub use clone::Clone;
 pub use cmp::{PartialEq, PartialOrd, Eq, Ord};
 pub use cmp::{Ordering, Less, Equal, Greater, Equiv};
-pub use collections::Collection;
 pub use iter::{FromIterator, Extendable};
 pub use iter::{Iterator, DoubleEndedIterator, RandomAccessIterator, CloneableIterator};
 pub use iter::{OrdIterator, MutableDoubleEndedIterator, ExactSize};
diff --git a/src/libcore/slice.rs b/src/libcore/slice.rs
index dd51534d319..317a6e224bc 100644
--- a/src/libcore/slice.rs
+++ b/src/libcore/slice.rs
@@ -36,7 +36,6 @@
 
 use mem::transmute;
 use clone::Clone;
-use collections::Collection;
 use cmp::{PartialEq, PartialOrd, Eq, Ord, Ordering, Less, Equal, Greater, Equiv};
 use cmp;
 use default::Default;
@@ -234,6 +233,29 @@ pub trait ImmutableSlice<T> for Sized? {
     /// ```
     #[unstable = "waiting on unboxed closures"]
     fn binary_search(&self, f: |&T| -> Ordering) -> BinarySearchResult;
+
+    /// Return the number of elements in the slice
+    ///
+    /// # Example
+    ///
+    /// ```
+    /// let a = [1i, 2, 3];
+    /// assert_eq!(a.len(), 3);
+    /// ```
+    #[experimental = "not triaged yet"]
+    fn len(&self) -> uint;
+
+    /// Returns true if the slice has a length of 0
+    ///
+    /// # Example
+    ///
+    /// ```
+    /// let a = [1i, 2, 3];
+    /// assert!(!a.is_empty());
+    /// ```
+    #[inline]
+    #[experimental = "not triaged yet"]
+    fn is_empty(&self) -> bool { self.len() == 0 }
 }
 
 #[unstable]
@@ -372,6 +394,9 @@ impl<T> ImmutableSlice<T> for [T] {
         }
         return NotFound(base);
     }
+
+    #[inline]
+    fn len(&self) -> uint { self.repr().len }
 }
 
 
@@ -886,24 +911,6 @@ impl<'a,T> AsSlice<T> for &'a [T] {
     fn as_slice<'a>(&'a self) -> &'a [T] { *self }
 }
 
-#[experimental = "trait is experimental"]
-impl<'a, T> Collection for &'a [T] {
-    /// Returns the length of a slice.
-    #[inline]
-    fn len(&self) -> uint {
-        self.repr().len
-    }
-}
-
-#[experimental = "trait is experimental"]
-impl<'a, T> Collection for &'a mut [T] {
-    /// Returns the length of a slice.
-    #[inline]
-    fn len(&self) -> uint {
-        self.repr().len
-    }
-}
-
 #[unstable = "waiting for DST"]
 impl<'a, T> Default for &'a [T] {
     fn default() -> &'a [T] { &[] }
@@ -1508,7 +1515,6 @@ pub mod raw {
 /// Operations on `[u8]`.
 #[experimental = "needs review"]
 pub mod bytes {
-    use collections::Collection;
     use kinds::Sized;
     use ptr;
     use slice::{ImmutableSlice, MutableSlice};
diff --git a/src/libcore/str.rs b/src/libcore/str.rs
index 86bbef861c4..dd8c7e9660a 100644
--- a/src/libcore/str.rs
+++ b/src/libcore/str.rs
@@ -22,7 +22,6 @@ use char::Char;
 use clone::Clone;
 use cmp;
 use cmp::{PartialEq, Eq};
-use collections::Collection;
 use default::Default;
 use iter::{Map, Iterator};
 use iter::{DoubleEndedIterator, ExactSize};
@@ -1057,7 +1056,6 @@ const TAG_CONT_U8: u8 = 0b1000_0000u8;
 /// Unsafe operations
 pub mod raw {
     use mem;
-    use collections::Collection;
     use ptr::RawPtr;
     use raw::Slice;
     use slice::{ImmutableSlice};
@@ -1121,7 +1119,6 @@ Section: Trait implementations
 #[allow(missing_docs)]
 pub mod traits {
     use cmp::{Ord, Ordering, Less, Equal, Greater, PartialEq, PartialOrd, Equiv, Eq};
-    use collections::Collection;
     use iter::Iterator;
     use option::{Option, Some};
     use ops;
@@ -1199,13 +1196,6 @@ impl<'a> Str for &'a str {
     fn as_slice<'a>(&'a self) -> &'a str { *self }
 }
 
-impl<'a> Collection for &'a str {
-    #[inline]
-    fn len(&self) -> uint {
-        self.repr().len
-    }
-}
-
 /// Methods for string slices
 pub trait StrSlice for Sized? {
     /// Returns true if one string contains another
@@ -1827,6 +1817,28 @@ pub trait StrSlice for Sized? {
 
     /// Return an iterator of `u16` over the string encoded as UTF-16.
     fn utf16_units<'a>(&'a self) -> Utf16CodeUnits<'a>;
+
+    /// Return the number of bytes in this string
+    ///
+    /// # Example
+    ///
+    /// ```
+    /// assert_eq!("foo".len(), 3);
+    /// assert_eq!("ƒoo".len(), 4);
+    /// ```
+    #[experimental = "not triaged yet"]
+    fn len(&self) -> uint;
+
+    /// Returns true if this slice contains no bytes
+    ///
+    /// # Example
+    ///
+    /// ```
+    /// assert!("".is_empty());
+    /// ```
+    #[inline]
+    #[experimental = "not triaged yet"]
+    fn is_empty(&self) -> bool { self.len() == 0 }
 }
 
 #[inline(never)]
@@ -2179,6 +2191,9 @@ impl StrSlice for str {
     fn utf16_units(&self) -> Utf16CodeUnits {
         Utf16CodeUnits{ chars: self.chars(), extra: 0}
     }
+
+    #[inline]
+    fn len(&self) -> uint { self.repr().len }
 }
 
 impl<'a> Default for &'a str {