Skip to content

Commit 465666d

Browse files
committed
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).
2 parents d3a58f3 + 8ae6b33 commit 465666d

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/libcore/str.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1863,7 +1863,7 @@ pub fn char_range_at(s: &str, i: uint) -> CharRange {
18631863
return CharRange {ch: val as char, next: i};
18641864
}
18651865

1866-
/// Plucks the `n`th character from the beginning of a string
1866+
/// Plucks the character starting at the `i`th byte of a string
18671867
pub fn char_at(s: &str, i: uint) -> char {
18681868
return char_range_at(s, i).ch;
18691869
}
@@ -1874,11 +1874,11 @@ pub struct CharRange {
18741874
}
18751875

18761876
/**
1877-
* Given a byte position and a str, return the previous char and its position
1877+
* Given a byte position and a str, return the previous char and its position.
18781878
*
18791879
* This function can be used to iterate over a unicode string in reverse.
18801880
*
1881-
* returns 0 for next index if called on start index 0
1881+
* Returns 0 for next index if called on start index 0.
18821882
*/
18831883
pub fn char_range_at_reverse(ss: &str, start: uint) -> CharRange {
18841884
let mut prev = start;
@@ -1900,7 +1900,7 @@ pub fn char_range_at_reverse(ss: &str, start: uint) -> CharRange {
19001900
return CharRange {ch:ch, next:prev};
19011901
}
19021902

1903-
/// Plucks the `n`th character from the end of a string
1903+
/// Plucks the character ending at the `i`th byte of a string
19041904
pub fn char_at_reverse(s: &str, i: uint) -> char {
19051905
char_range_at_reverse(s, i).ch
19061906
}

0 commit comments

Comments
 (0)