diff options
| author | Corey Richardson <corey@octayn.net> | 2014-06-18 10:40:38 -0700 |
|---|---|---|
| committer | Corey Richardson <corey@octayn.net> | 2014-07-09 00:06:28 -0700 |
| commit | 3c7f619b76b87c400e270eebfa7625844afcd673 (patch) | |
| tree | 621e5f082dd82d9252a67a5fadcab3425eccd0a5 /src/libcore | |
| parent | c2dd553bed572368953801dd1d339013f58b53d6 (diff) | |
| download | rust-3c7f619b76b87c400e270eebfa7625844afcd673.tar.gz rust-3c7f619b76b87c400e270eebfa7625844afcd673.zip | |
str: use more helpful assertion failure messages
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/str.rs | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/libcore/str.rs b/src/libcore/str.rs index 94df7a5a6c2..f94d5a5e4b5 100644 --- a/src/libcore/str.rs +++ b/src/libcore/str.rs @@ -1764,7 +1764,9 @@ impl<'a> StrSlice<'a> for &'a str { #[inline] 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) } } @@ -1775,7 +1777,8 @@ impl<'a> StrSlice<'a> for &'a str { #[inline] 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) } } |
