Add additonal case for Path starts with

Show what happens if there is an extra extension
This commit is contained in:
Ivan Tham 2020-08-08 18:06:04 +08:00 committed by GitHub
parent d19d7e2755
commit e7e41a8465
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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 {