Skip to content

Commit 02b8e4e

Browse files
author
Ulrik Sverdrup
committed
docs: Clarify Path::starts_with (and ends_with)
Fixes rust-lang#24882
1 parent 4e8afd6 commit 02b8e4e

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/libstd/path.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1449,6 +1449,8 @@ impl Path {
14491449

14501450
/// Determines whether `base` is a prefix of `self`.
14511451
///
1452+
/// Only considers whole path components to match.
1453+
///
14521454
/// # Examples
14531455
///
14541456
/// ```
@@ -1457,6 +1459,8 @@ impl Path {
14571459
/// let path = Path::new("/etc/passwd");
14581460
///
14591461
/// assert!(path.starts_with("/etc"));
1462+
///
1463+
/// assert!(!path.starts_with("/e"));
14601464
/// ```
14611465
#[stable(feature = "rust1", since = "1.0.0")]
14621466
pub fn starts_with<P: AsRef<Path>>(&self, base: P) -> bool {
@@ -1465,6 +1469,8 @@ impl Path {
14651469

14661470
/// Determines whether `child` is a suffix of `self`.
14671471
///
1472+
/// Only considers whole path components to match.
1473+
///
14681474
/// # Examples
14691475
///
14701476
/// ```

0 commit comments

Comments
 (0)