std::str: Only check char boundary for end index in .slice_to()

This commit is contained in:
blake2-ppc
2013-08-18 21:28:04 +02:00
parent f33a30e7e8
commit 8931ad9e52

View File

@@ -1427,7 +1427,8 @@ impl<'self> StrSlice<'self> for &'self str {
/// out of bounds.
#[inline]
fn slice_to(&self, end: uint) -> &'self str {
self.slice(0, end)
assert!(self.is_char_boundary(end));
unsafe { raw::slice_bytes(*self, 0, end) }
}
/// Returns a slice of the string from the char range