about summary refs log tree commit diff
path: root/src/libcollections/string.rs
diff options
context:
space:
mode:
authorMatt Ickstadt <mattico8@gmail.com>2017-04-08 16:12:58 -0500
committerMatt Ickstadt <mattico8@gmail.com>2017-04-23 21:23:45 -0500
commitb85e2e4735fe78fffeecd2fce96d7ce40d22438c (patch)
tree76388e913c195a5d7c5e15b5b637d04292cbadb2 /src/libcollections/string.rs
parent2111aff682ee4ced9dca27defb4643cc78ab8762 (diff)
downloadrust-b85e2e4735fe78fffeecd2fce96d7ce40d22438c.tar.gz
rust-b85e2e4735fe78fffeecd2fce96d7ce40d22438c.zip
Update splice impl
Diffstat (limited to 'src/libcollections/string.rs')
-rw-r--r--src/libcollections/string.rs13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/libcollections/string.rs b/src/libcollections/string.rs
index 8090bc1996e..cc4f9b86be4 100644
--- a/src/libcollections/string.rs
+++ b/src/libcollections/string.rs
@@ -1421,8 +1421,16 @@ impl String {
         // Because the range removal happens in Drop, if the Splice iterator is leaked,
         // the removal will not happen.
         let len = self.len();
-        let start = *range.start().unwrap_or(&0);
-        let end = *range.end().unwrap_or(&len);
+        let start = match range.start() {
+             Included(&n) => n,
+             Excluded(&n) => n + 1,
+             Unbounded => 0,
+        };
+        let end = match range.end() {
+             Included(&n) => n + 1,
+             Excluded(&n) => n,
+             Unbounded => len,
+        };
 
         // Take out two simultaneous borrows. The &mut String won't be accessed
         // until iteration is over, in Drop.
@@ -2210,6 +2218,7 @@ impl<'a> FusedIterator for Drain<'a> {}
 ///
 /// [`splice()`]: struct.String.html#method.splice
 /// [`String`]: struct.String.html
+#[derive(Debug)]
 #[unstable(feature = "splice", reason = "recently added", issue = "32310")]
 pub struct Splice<'a, 'b> {
     /// Will be used as &'a mut String in the destructor