]> git.lizzy.rs Git - rust.git/commitdiff
docs: Clarify Path::starts_with (and ends_with)
authorUlrik Sverdrup <root@localhost>
Sun, 10 May 2015 22:29:50 +0000 (00:29 +0200)
committerUlrik Sverdrup <root@localhost>
Mon, 11 May 2015 01:41:53 +0000 (03:41 +0200)
Fixes #24882

src/libstd/path.rs

index 8ccc387c9027788adb1e7603bdbc34f1a01a58d4..21f873e687743ed7918202f9b3f10e3ecb12d6b9 100644 (file)
@@ -1449,6 +1449,8 @@ pub fn relative_from<'a, P: ?Sized + AsRef<Path>>(&'a self, base: &'a P) -> Opti
 
     /// Determines whether `base` is a prefix of `self`.
     ///
+    /// Only considers whole path components to match.
+    ///
     /// # Examples
     ///
     /// ```
@@ -1457,6 +1459,8 @@ pub fn relative_from<'a, P: ?Sized + AsRef<Path>>(&'a self, base: &'a P) -> Opti
     /// let path = Path::new("/etc/passwd");
     ///
     /// assert!(path.starts_with("/etc"));
+    ///
+    /// assert!(!path.starts_with("/e"));
     /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
     pub fn starts_with<P: AsRef<Path>>(&self, base: P) -> bool {
@@ -1465,6 +1469,8 @@ pub fn starts_with<P: AsRef<Path>>(&self, base: P) -> bool {
 
     /// Determines whether `child` is a suffix of `self`.
     ///
+    /// Only considers whole path components to match.
+    ///
     /// # Examples
     ///
     /// ```