str: use more helpful assertion failure messages
This commit is contained in:
@@ -1764,7 +1764,9 @@ impl<'a> StrSlice<'a> for &'a str {
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn slice(&self, begin: uint, end: uint) -> &'a str {
|
fn slice(&self, begin: uint, end: uint) -> &'a str {
|
||||||
assert!(self.is_char_boundary(begin) && self.is_char_boundary(end));
|
assert!(self.is_char_boundary(begin) && self.is_char_boundary(end),
|
||||||
|
"index {} and/or {} in `{}` do not lie on character boundary", begin,
|
||||||
|
end, *self);
|
||||||
unsafe { raw::slice_bytes(*self, begin, end) }
|
unsafe { raw::slice_bytes(*self, begin, end) }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1775,7 +1777,8 @@ impl<'a> StrSlice<'a> for &'a str {
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn slice_to(&self, end: uint) -> &'a str {
|
fn slice_to(&self, end: uint) -> &'a str {
|
||||||
assert!(self.is_char_boundary(end));
|
assert!(self.is_char_boundary(end), "index {} in `{}` does not lie on \
|
||||||
|
a character boundary", end, *self);
|
||||||
unsafe { raw::slice_bytes(*self, 0, end) }
|
unsafe { raw::slice_bytes(*self, 0, end) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user