Skip to content

Commit 8931ad9

Browse files
author
blake2-ppc
committed
std::str: Only check char boundary for end index in .slice_to()
1 parent f33a30e commit 8931ad9

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/libstd/str.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1427,7 +1427,8 @@ impl<'self> StrSlice<'self> for &'self str {
14271427
/// out of bounds.
14281428
#[inline]
14291429
fn slice_to(&self, end: uint) -> &'self str {
1430-
self.slice(0, end)
1430+
assert!(self.is_char_boundary(end));
1431+
unsafe { raw::slice_bytes(*self, 0, end) }
14311432
}
14321433
14331434
/// Returns a slice of the string from the char range

0 commit comments

Comments
 (0)