diff options
| author | bors <bors@rust-lang.org> | 2013-04-19 05:45:51 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-04-19 05:45:51 -0700 |
| commit | 465666d5c85fd4b97551bd1caa5fdc9bc59bd10b (patch) | |
| tree | 187d15f4bb1886f7a8ba1810b29c8b0a2ec663ce | |
| parent | d3a58f37979496efdf15bf016ebccc17b007a6cc (diff) | |
| parent | 8ae6b33ed0cf2b1793773f31b8f5249347ef0983 (diff) | |
| download | rust-465666d5c85fd4b97551bd1caa5fdc9bc59bd10b.tar.gz rust-465666d5c85fd4b97551bd1caa5fdc9bc59bd10b.zip | |
auto merge of #5957 : huonw/rust/core-char-at-doc, r=thestinger
The documentation was unclear/wrong: it implies the functions operated on unicode char indices, but they actually operate on byte indices. Also, the `char_at_reverse` documentation was unclear whether it counted from the beginning or the end (causing #5956).
| -rw-r--r-- | src/libcore/str.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/libcore/str.rs b/src/libcore/str.rs index 7cc3a694c56..cb362b2e6c0 100644 --- a/src/libcore/str.rs +++ b/src/libcore/str.rs @@ -1863,7 +1863,7 @@ pub fn char_range_at(s: &str, i: uint) -> CharRange { return CharRange {ch: val as char, next: i}; } -/// Plucks the `n`th character from the beginning of a string +/// Plucks the character starting at the `i`th byte of a string pub fn char_at(s: &str, i: uint) -> char { return char_range_at(s, i).ch; } @@ -1874,11 +1874,11 @@ pub struct CharRange { } /** - * Given a byte position and a str, return the previous char and its position + * Given a byte position and a str, return the previous char and its position. * * This function can be used to iterate over a unicode string in reverse. * - * returns 0 for next index if called on start index 0 + * Returns 0 for next index if called on start index 0. */ pub fn char_range_at_reverse(ss: &str, start: uint) -> CharRange { let mut prev = start; @@ -1900,7 +1900,7 @@ pub fn char_range_at_reverse(ss: &str, start: uint) -> CharRange { return CharRange {ch:ch, next:prev}; } -/// Plucks the `n`th character from the end of a string +/// Plucks the character ending at the `i`th byte of a string pub fn char_at_reverse(s: &str, i: uint) -> char { char_range_at_reverse(s, i).ch } |
