From 4657e14dc43dbb4f8e0aec7e7619636711bb2788 Mon Sep 17 00:00:00 2001 From: Young Woo Date: Thu, 11 Dec 2014 13:43:03 +0800 Subject: [PATCH] char_at_reverse(0) returns the first char of str could this be a bug? misunderstood the char_range_at_reverse methods? --- src/libcore/str.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/libcore/str.rs b/src/libcore/str.rs index baa739b06833c..d989925fb3c18 100644 --- a/src/libcore/str.rs +++ b/src/libcore/str.rs @@ -18,7 +18,6 @@ pub use self::Utf16Item::*; pub use self::Searcher::{Naive, TwoWay, TwoWayLong}; - use char::Char; use char; use cmp::{Eq, mod}; @@ -2242,7 +2241,7 @@ impl StrPrelude for str { #[inline] fn char_at_reverse(&self, i: uint) -> char { - self.char_range_at_reverse(i).ch + self.char_range_at_reverse(self.len() - i + 1).ch } #[inline]