Skip to content

Document failure cases for char_at and friends. #14609

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 3, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions src/libcore/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down