Skip to content

Commit df2da46

Browse files
authored
Rollup merge of #75286 - pickfire:patch-9, r=jyn514
Add additional case for Path starts with Show what happens if there is an extra extension
2 parents 62e5488 + 4b549fa commit df2da46

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

library/std/src/path.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -2031,9 +2031,13 @@ impl Path {
20312031
/// assert!(path.starts_with("/etc"));
20322032
/// assert!(path.starts_with("/etc/"));
20332033
/// assert!(path.starts_with("/etc/passwd"));
2034-
/// assert!(path.starts_with("/etc/passwd/"));
2034+
/// assert!(path.starts_with("/etc/passwd/")); // extra slash is okay
2035+
/// assert!(path.starts_with("/etc/passwd///")); // multiple extra slashes are okay
20352036
///
20362037
/// assert!(!path.starts_with("/e"));
2038+
/// assert!(!path.starts_with("/etc/passwd.txt"));
2039+
///
2040+
/// assert!(!Path::new("/etc/foo.rs").starts_with("/etc/foo"));
20372041
/// ```
20382042
#[stable(feature = "rust1", since = "1.0.0")]
20392043
pub fn starts_with<P: AsRef<Path>>(&self, base: P) -> bool {

0 commit comments

Comments
 (0)