about summary refs log tree commit diff
diff options
context:
space:
mode:
authorIvan Tham <pickfire@riseup.net>2020-08-08 18:06:04 +0800
committerGitHub <noreply@github.com>2020-08-08 18:06:04 +0800
commite7e41a846578de9c1dc1ccf8ac4bbb0a3a5dea60 (patch)
treee96348d5b87e541aa4a77a4656b80555531fb419
parentd19d7e27552b8da17932384b8db53927a1f4e00e (diff)
downloadrust-e7e41a846578de9c1dc1ccf8ac4bbb0a3a5dea60.tar.gz
rust-e7e41a846578de9c1dc1ccf8ac4bbb0a3a5dea60.zip
Add additonal case for Path starts with
Show what happens if there is an extra extension
-rw-r--r--library/std/src/path.rs5
1 files changed, 4 insertions, 1 deletions
diff --git a/library/std/src/path.rs b/library/std/src/path.rs
index 392c815ef28..e8aa9e27c0f 100644
--- a/library/std/src/path.rs
+++ b/library/std/src/path.rs
@@ -2087,9 +2087,12 @@ impl Path {
     /// assert!(path.starts_with("/etc"));
     /// assert!(path.starts_with("/etc/"));
     /// assert!(path.starts_with("/etc/passwd"));
-    /// assert!(path.starts_with("/etc/passwd/"));
+    /// assert!(path.starts_with("/etc/passwd/")); // extra slash(es) is okay
     ///
     /// assert!(!path.starts_with("/e"));
+    /// assert!(!path.starts_with("/etc/passwd.txt"));
+    ///
+    /// assert!(!Path::new("/etc/foo.rs").starts_with("/etc/foo"));
     /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
     pub fn starts_with<P: AsRef<Path>>(&self, base: P) -> bool {