]> git.lizzy.rs Git - rust.git/blobdiff - src/libstd/str.rs
Merge remote-tracking branch 'huonw/inline-helpers'
[rust.git] / src / libstd / str.rs
index ecd297b72a41b61debfc6d3c7cc3c01b2dc90d98..3c094cd631d76b882176bd0464e6cf7ed22465d2 100644 (file)
@@ -17,7 +17,7 @@
 Rust's string type is one of the core primitive types of the language. While
 represented by the name `str`, the name `str` is not actually a valid type in
 Rust. Each string must also be decorated with its ownership. This means that
-there are two common kinds of strings in rust:
+there are two common kinds of strings in Rust:
 
 * `~str` - This is an owned string. This type obeys all of the normal semantics
            of the `~T` types, meaning that it has one, and only one, owner. This
@@ -39,7 +39,7 @@ fn main() {
 }
  ```
 
-From the example above, you can see that rust has 2 different kinds of string
+From the example above, you can see that Rust has 2 different kinds of string
 literals. The owned literals correspond to the owned string types, but the
 "borrowed literal" is actually more akin to C's concept of a static string.
 
@@ -51,7 +51,7 @@ fn main() {
 
 # Mutability
 
-Many languages have immutable strings by default, and rust has a particular
+Many languages have immutable strings by default, and Rust has a particular
 flavor on this idea. As with the rest of Rust types, strings are immutable by
 default. If a string is declared as `mut`, however, it may be mutated. This
 works the same way as the rest of Rust's type system in the sense that if
@@ -89,6 +89,7 @@ fn main() {
 use cmp::{Eq, TotalEq, Ord, TotalOrd, Equiv, Ordering};
 use container::{Container, Mutable};
 use fmt;
+use hash::{Hash, sip};
 use iter::{Iterator, FromIterator, Extendable, range};
 use iter::{Filter, AdditiveIterator, Map};
 use iter::{Rev, DoubleEndedIterator, ExactSize};
@@ -103,8 +104,7 @@ fn main() {
 use vec::{OwnedVector, OwnedCloneableVector, ImmutableVector, MutableVector};
 use vec_ng::Vec;
 use default::Default;
-use to_bytes::{IterBytes, Cb};
-use unstable::raw::Repr;
+use raw::Repr;
 
 /*
 Section: Creating a string
@@ -1357,13 +1357,10 @@ impl<'a> Default for MaybeOwned<'a> {
     fn default() -> MaybeOwned<'a> { Slice("") }
 }
 
-impl<'a> IterBytes for MaybeOwned<'a> {
+impl<'a> Hash for MaybeOwned<'a> {
     #[inline]
-    fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool {
-        match *self {
-            Slice(s) => s.iter_bytes(lsb0, f),
-            Owned(ref s) => s.iter_bytes(lsb0, f)
-        }
+    fn hash(&self, s: &mut sip::SipState) {
+        self.as_slice().hash(s)
     }
 }
 
@@ -1387,7 +1384,7 @@ pub mod raw {
     use str::{is_utf8, OwnedStr, StrSlice};
     use vec;
     use vec::{MutableVector, ImmutableVector, OwnedVector};
-    use unstable::raw::Slice;
+    use raw::Slice;
 
     /// Create a Rust string from a *u8 buffer of the given length
     pub unsafe fn from_buf_len(buf: *u8, len: uint) -> ~str {