]> git.lizzy.rs Git - rust.git/commitdiff
Document failure cases for `char_at` and friends.
authorAaron Turon <aturon@mozilla.com>
Mon, 2 Jun 2014 22:22:17 +0000 (15:22 -0700)
committerAaron Turon <aturon@mozilla.com>
Mon, 2 Jun 2014 22:22:17 +0000 (15:22 -0700)
src/libcore/str.rs

index c83b1d09283bb26d9ab38c15ed24005fe581a2be..c08f30152d5928ed1609325d276e72d307bba90e 100644 (file)
@@ -1475,12 +1475,27 @@ pub trait StrSlice<'a> {
     /// This function can be used to iterate over a unicode string in reverse.
     ///
     /// Returns 0 for next index if called on start index 0.
+    ///
+    /// # Failure
+    ///
+    /// If `i` is greater than the length of the string.
+    /// If `i` is not an index following a valid UTF-8 character.
     fn char_range_at_reverse(&self, start: uint) -> CharRange;
 
-    /// Plucks the character starting at the `i`th byte of a string
+    /// Plucks the character starting at the `i`th byte of a string.
+    ///
+    /// # Failure
+    ///
+    /// If `i` is greater than or equal to the length of the string.
+    /// If `i` is not the index of the beginning of a valid UTF-8 character.
     fn char_at(&self, i: uint) -> char;
 
-    /// Plucks the character ending at the `i`th byte of a string
+    /// Plucks the character ending at the `i`th byte of a string.
+    ///
+    /// # Failure
+    ///
+    /// If `i` is greater than the length of the string.
+    /// If `i` is not an index following a valid UTF-8 character.
     fn char_at_reverse(&self, i: uint) -> char;
 
     /// Work with the byte buffer of a string as a byte slice.