Skip to content

Commit e7e41a8

Browse files
authored
Add additonal case for Path starts with
Show what happens if there is an extra extension
1 parent d19d7e2 commit e7e41a8

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

library/std/src/path.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -2087,9 +2087,12 @@ impl Path {
20872087
/// assert!(path.starts_with("/etc"));
20882088
/// assert!(path.starts_with("/etc/"));
20892089
/// assert!(path.starts_with("/etc/passwd"));
2090-
/// assert!(path.starts_with("/etc/passwd/"));
2090+
/// assert!(path.starts_with("/etc/passwd/")); // extra slash(es) is okay
20912091
///
20922092
/// assert!(!path.starts_with("/e"));
2093+
/// assert!(!path.starts_with("/etc/passwd.txt"));
2094+
///
2095+
/// assert!(!Path::new("/etc/foo.rs").starts_with("/etc/foo"));
20932096
/// ```
20942097
#[stable(feature = "rust1", since = "1.0.0")]
20952098
pub fn starts_with<P: AsRef<Path>>(&self, base: P) -> bool {

0 commit comments

Comments
 (0)