]> git.proxmox.com Git - rustc.git/blobdiff - vendor/url/src/path_segments.rs
Merge tag 'debian/1.52.1+dfsg1-1_exp2' into proxmox/buster
[rustc.git] / vendor / url / src / path_segments.rs
index f2ae67e49db4b975f9579cf1be2cae54863e434f..29afc1e7e933048e4cf4bd5019cb348947386ff0 100644 (file)
@@ -123,6 +123,9 @@ impl<'a> PathSegmentsMut<'a> {
     /// # run().unwrap();
     /// ```
     pub fn pop_if_empty(&mut self) -> &mut Self {
+        if self.after_first_slash >= self.url.serialization.len() {
+            return self;
+        }
         if self.url.serialization[self.after_first_slash..].ends_with('/') {
             self.url.serialization.pop();
         }
@@ -135,6 +138,9 @@ impl<'a> PathSegmentsMut<'a> {
     ///
     /// Returns `&mut Self` so that method calls can be chained.
     pub fn pop(&mut self) -> &mut Self {
+        if self.after_first_slash >= self.url.serialization.len() {
+            return self;
+        }
         let last_slash = self.url.serialization[self.after_first_slash..]
             .rfind('/')
             .unwrap_or(0);