about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-01-31 22:21:38 -0800
committerbors <bors@rust-lang.org>2014-01-31 22:21:38 -0800
commit5c5d995126ac3e9b4629a55fce941c558d5bb0cb (patch)
tree454a14962add2bfc63aa8c0beff080daf313a15e /src/libstd
parentcc6afe1ec0d3e5e9da4c0f7d0443991afe74dfaf (diff)
parenta67a3b7749c9a0544b2fe69338c17c6314be935d (diff)
downloadrust-5c5d995126ac3e9b4629a55fce941c558d5bb0cb.tar.gz
rust-5c5d995126ac3e9b4629a55fce941c558d5bb0cb.zip
auto merge of #11965 : alexcrichton/rust/issue-7385, r=alexcrichton
I've verified that it works on osx x86_64

Closes #7385

Rolled up PRs:

Closes #11898
Closes #11934
Closes #11942
Closes #11952 
Closes #11960 
Closes #11966
Closes #11953 

Closed issues:

Closes #4063 
Closes #7911
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/any.rs4
-rw-r--r--src/libstd/ascii.rs10
-rw-r--r--src/libstd/c_str.rs39
-rw-r--r--src/libstd/io/mod.rs2
-rw-r--r--src/libstd/iter.rs2
-rw-r--r--src/libstd/num/f32.rs8
-rw-r--r--src/libstd/num/f64.rs8
-rw-r--r--src/libstd/num/strconv.rs4
-rw-r--r--src/libstd/option.rs2
-rw-r--r--src/libstd/result.rs4
-rw-r--r--src/libstd/send_str.rs4
-rw-r--r--src/libstd/str.rs4
-rw-r--r--src/libstd/vec.rs2
13 files changed, 63 insertions, 30 deletions
diff --git a/src/libstd/any.rs b/src/libstd/any.rs
index 814cf328771..72ccf6be023 100644
--- a/src/libstd/any.rs
+++ b/src/libstd/any.rs
@@ -1,4 +1,4 @@
-// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
+// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
 // file at the top-level directory of this distribution and at
 // http://rust-lang.org/COPYRIGHT.
 //
@@ -118,7 +118,7 @@ impl<'a> AnyMutRefExt<'a> for &'a mut Any {
     }
 }
 
-/// Extension methods for a owning `Any` trait object
+/// Extension methods for an owning `Any` trait object
 pub trait AnyOwnExt {
     /// Returns the boxed value if it is of type `T`, or
     /// `Err(Self)` if it isn't.
diff --git a/src/libstd/ascii.rs b/src/libstd/ascii.rs
index 546f5550387..83aec9d0aa6 100644
--- a/src/libstd/ascii.rs
+++ b/src/libstd/ascii.rs
@@ -1,4 +1,4 @@
-// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
+// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
 // file at the top-level directory of this distribution and at
 // http://rust-lang.org/COPYRIGHT.
 //
@@ -27,13 +27,13 @@ use option::{Option, Some, None};
 pub struct Ascii { priv chr: u8 }
 
 impl Ascii {
-    /// Converts a ascii character into a `u8`.
+    /// Converts an ascii character into a `u8`.
     #[inline]
     pub fn to_byte(self) -> u8 {
         self.chr
     }
 
-    /// Converts a ascii character into a `char`.
+    /// Converts an ascii character into a `char`.
     #[inline]
     pub fn to_char(self) -> char {
         self.chr as char
@@ -314,9 +314,9 @@ impl IterBytes for Ascii {
     }
 }
 
-/// Trait to convert to a owned byte array by consuming self
+/// Trait to convert to an owned byte array by consuming self
 pub trait IntoBytes {
-    /// Converts to a owned byte array by consuming self
+    /// Converts to an owned byte array by consuming self
     fn into_bytes(self) -> ~[u8];
 }
 
diff --git a/src/libstd/c_str.rs b/src/libstd/c_str.rs
index ded80d07003..b7374b6f15d 100644
--- a/src/libstd/c_str.rs
+++ b/src/libstd/c_str.rs
@@ -162,17 +162,25 @@ impl CString {
     }
 
     /// Converts the CString into a `&str` without copying.
-    /// Returns None if the CString is not UTF-8 or is null.
+    /// Returns None if the CString is not UTF-8.
+    ///
+    /// # Failure
+    ///
+    /// Fails if the CString is null.
     #[inline]
     pub fn as_str<'a>(&'a self) -> Option<&'a str> {
-        if self.buf.is_null() { return None; }
         let buf = self.as_bytes();
         let buf = buf.slice_to(buf.len()-1); // chop off the trailing NUL
         str::from_utf8(buf)
     }
 
     /// Return a CString iterator.
+    ///
+    /// # Failure
+    ///
+    /// Fails if the CString is null.
     pub fn iter<'a>(&'a self) -> CChars<'a> {
+        if self.buf.is_null() { fail!("CString is null!"); }
         CChars {
             ptr: self.buf,
             marker: marker::ContravariantLifetime,
@@ -191,8 +199,14 @@ impl Drop for CString {
 }
 
 impl Container for CString {
+    /// Return the number of bytes in the CString (not including the NUL terminator).
+    ///
+    /// # Failure
+    ///
+    /// Fails if the CString is null.
     #[inline]
     fn len(&self) -> uint {
+        if self.buf.is_null() { fail!("CString is null!"); }
         unsafe {
             ptr::position(self.buf, |c| *c == 0)
         }
@@ -562,8 +576,27 @@ mod tests {
         assert_eq!(c_str.as_str(), Some(""));
         let c_str = bytes!("foo", 0xff).to_c_str();
         assert_eq!(c_str.as_str(), None);
+    }
+
+    #[test]
+    #[should_fail]
+    fn test_as_str_fail() {
         let c_str = unsafe { CString::new(ptr::null(), false) };
-        assert_eq!(c_str.as_str(), None);
+        c_str.as_str();
+    }
+
+    #[test]
+    #[should_fail]
+    fn test_len_fail() {
+        let c_str = unsafe { CString::new(ptr::null(), false) };
+        c_str.len();
+    }
+
+    #[test]
+    #[should_fail]
+    fn test_iter_fail() {
+        let c_str = unsafe { CString::new(ptr::null(), false) };
+        c_str.iter();
     }
 }
 
diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs
index cadcbdd51f5..69f0cf96ffc 100644
--- a/src/libstd/io/mod.rs
+++ b/src/libstd/io/mod.rs
@@ -83,7 +83,7 @@ Some examples of obvious things you might want to do
     let lines: ~[~str] = file.lines().collect();
     ```
 
-* Make an simple HTTP request
+* Make a simple HTTP request
   FIXME This needs more improvement: TcpStream constructor taking &str,
   `write_str` and `write_line` methods.
 
diff --git a/src/libstd/iter.rs b/src/libstd/iter.rs
index 5a38b7cb2e1..df7b04dcd19 100644
--- a/src/libstd/iter.rs
+++ b/src/libstd/iter.rs
@@ -213,7 +213,7 @@ pub trait Iterator<A> {
 
 
     /// Creates an iterator that has a `.peek()` method
-    /// that returns a optional reference to the next element.
+    /// that returns an optional reference to the next element.
     ///
     /// # Example
     ///
diff --git a/src/libstd/num/f32.rs b/src/libstd/num/f32.rs
index 8acfd197618..a4b6aca86f7 100644
--- a/src/libstd/num/f32.rs
+++ b/src/libstd/num/f32.rs
@@ -1,4 +1,4 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
+// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
 // file at the top-level directory of this distribution and at
 // http://rust-lang.org/COPYRIGHT.
 //
@@ -812,7 +812,7 @@ impl num::ToStrRadix for f32 {
 }
 
 /// Convert a string in base 16 to a float.
-/// Accepts a optional binary exponent.
+/// Accepts an optional binary exponent.
 ///
 /// This function accepts strings such as
 ///
@@ -844,7 +844,7 @@ pub fn from_str_hex(num: &str) -> Option<f32> {
 
 impl FromStr for f32 {
     /// Convert a string in base 10 to a float.
-    /// Accepts a optional decimal exponent.
+    /// Accepts an optional decimal exponent.
     ///
     /// This function accepts strings such as
     ///
@@ -876,7 +876,7 @@ impl FromStr for f32 {
 }
 
 impl num::FromStrRadix for f32 {
-    /// Convert a string in an given base to a float.
+    /// Convert a string in a given base to a float.
     ///
     /// Due to possible conflicts, this function does **not** accept
     /// the special values `inf`, `-inf`, `+inf` and `NaN`, **nor**
diff --git a/src/libstd/num/f64.rs b/src/libstd/num/f64.rs
index 6bb7bf6c563..d51f6b602d7 100644
--- a/src/libstd/num/f64.rs
+++ b/src/libstd/num/f64.rs
@@ -1,4 +1,4 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
+// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
 // file at the top-level directory of this distribution and at
 // http://rust-lang.org/COPYRIGHT.
 //
@@ -814,7 +814,7 @@ impl num::ToStrRadix for f64 {
 }
 
 /// Convert a string in base 16 to a float.
-/// Accepts a optional binary exponent.
+/// Accepts an optional binary exponent.
 ///
 /// This function accepts strings such as
 ///
@@ -846,7 +846,7 @@ pub fn from_str_hex(num: &str) -> Option<f64> {
 
 impl FromStr for f64 {
     /// Convert a string in base 10 to a float.
-    /// Accepts a optional decimal exponent.
+    /// Accepts an optional decimal exponent.
     ///
     /// This function accepts strings such as
     ///
@@ -878,7 +878,7 @@ impl FromStr for f64 {
 }
 
 impl num::FromStrRadix for f64 {
-    /// Convert a string in an given base to a float.
+    /// Convert a string in a given base to a float.
     ///
     /// Due to possible conflicts, this function does **not** accept
     /// the special values `inf`, `-inf`, `+inf` and `NaN`, **nor**
diff --git a/src/libstd/num/strconv.rs b/src/libstd/num/strconv.rs
index 67f6d006b57..1ecabff8758 100644
--- a/src/libstd/num/strconv.rs
+++ b/src/libstd/num/strconv.rs
@@ -1,4 +1,4 @@
-// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
+// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
 // file at the top-level directory of this distribution and at
 // http://rust-lang.org/COPYRIGHT.
 //
@@ -517,7 +517,7 @@ static DIGIT_E_RADIX: uint = ('e' as uint) - ('a' as uint) + 11u;
  *     - `ExpBin`:  Accepts numbers with a binary exponent like `42P-8` or
  *                  `FFp128`. The exponent string itself is always base 10.
  *                  Can conflict with `radix`, see Failure.
- * - `empty_zero` - Whether to accept a empty `buf` as a 0 or not.
+ * - `empty_zero` - Whether to accept an empty `buf` as a 0 or not.
  * - `ignore_underscores` - Whether all underscores within the string should
  *                          be ignored.
  *
diff --git a/src/libstd/option.rs b/src/libstd/option.rs
index 833f2021043..fd5f3a233e6 100644
--- a/src/libstd/option.rs
+++ b/src/libstd/option.rs
@@ -121,7 +121,7 @@ impl<T> Option<T> {
     // Getting to contained values
     /////////////////////////////////////////////////////////////////////////
 
-    /// Unwraps a option, yielding the content of a `Some`
+    /// Unwraps an option, yielding the content of a `Some`
     /// Fails if the value is a `None` with a custom failure message provided by `msg`.
     #[inline]
     pub fn expect<M: Any + Send>(self, msg: M) -> T {
diff --git a/src/libstd/result.rs b/src/libstd/result.rs
index c3618bad18e..4783c983d00 100644
--- a/src/libstd/result.rs
+++ b/src/libstd/result.rs
@@ -102,7 +102,7 @@ impl<T, E> Result<T, E> {
     // Transforming contained values
     /////////////////////////////////////////////////////////////////////////
 
-    /// Maps an `Result<T, E>` to `Result<U, E>` by applying a function to an
+    /// Maps a `Result<T, E>` to `Result<U, E>` by applying a function to an
     /// contained `Ok` value, leaving an `Err` value untouched.
     ///
     /// This function can be used to compose the results of two functions.
@@ -120,7 +120,7 @@ impl<T, E> Result<T, E> {
         }
     }
 
-    /// Maps an `Result<T, E>` to `Result<T, F>` by applying a function to an
+    /// Maps a `Result<T, E>` to `Result<T, F>` by applying a function to an
     /// contained `Err` value, leaving an `Ok` value untouched.
     ///
     /// This function can be used to pass through a successful result while handling
diff --git a/src/libstd/send_str.rs b/src/libstd/send_str.rs
index b6c9acd2672..2599a74a748 100644
--- a/src/libstd/send_str.rs
+++ b/src/libstd/send_str.rs
@@ -1,4 +1,4 @@
-// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
+// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
 // file at the top-level directory of this distribution and at
 // http://rust-lang.org/COPYRIGHT.
 //
@@ -38,7 +38,7 @@ impl SendStr {
         }
     }
 
-    /// Returns `true` if this `SendStr` wraps an static string
+    /// Returns `true` if this `SendStr` wraps a static string
     #[inline]
     pub fn is_static(&self) -> bool {
         match *self {
diff --git a/src/libstd/str.rs b/src/libstd/str.rs
index 9cc9799d0c0..16af8367edf 100644
--- a/src/libstd/str.rs
+++ b/src/libstd/str.rs
@@ -1,4 +1,4 @@
-// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
+// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
 // file at the top-level directory of this distribution and at
 // http://rust-lang.org/COPYRIGHT.
 //
@@ -417,7 +417,7 @@ pub struct CharSplitsN<'a, Sep> {
     priv invert: bool,
 }
 
-/// An iterator over the words of a string, separated by an sequence of whitespace
+/// An iterator over the words of a string, separated by a sequence of whitespace
 pub type Words<'a> =
     Filter<'a, &'a str, CharSplits<'a, extern "Rust" fn(char) -> bool>>;
 
diff --git a/src/libstd/vec.rs b/src/libstd/vec.rs
index bdb6077f984..8e733686472 100644
--- a/src/libstd/vec.rs
+++ b/src/libstd/vec.rs
@@ -804,7 +804,7 @@ pub trait CloneableVector<T> {
     /// Copy `self` into a new owned vector
     fn to_owned(&self) -> ~[T];
 
-    /// Convert `self` into a owned vector, not making a copy if possible.
+    /// Convert `self` into an owned vector, not making a copy if possible.
     fn into_owned(self) -> ~[T];
 }