提交 02b8e4e6 编写于 作者: U Ulrik Sverdrup

docs: Clarify Path::starts_with (and ends_with)

Fixes #24882
上级 4e8afd65
...@@ -1449,6 +1449,8 @@ pub fn relative_from<'a, P: ?Sized + AsRef<Path>>(&'a self, base: &'a P) -> Opti ...@@ -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`. /// Determines whether `base` is a prefix of `self`.
/// ///
/// Only considers whole path components to match.
///
/// # Examples /// # Examples
/// ///
/// ``` /// ```
...@@ -1457,6 +1459,8 @@ pub fn relative_from<'a, P: ?Sized + AsRef<Path>>(&'a self, base: &'a P) -> Opti ...@@ -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"); /// let path = Path::new("/etc/passwd");
/// ///
/// assert!(path.starts_with("/etc")); /// assert!(path.starts_with("/etc"));
///
/// assert!(!path.starts_with("/e"));
/// ``` /// ```
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
pub fn starts_with<P: AsRef<Path>>(&self, base: P) -> bool { 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 { ...@@ -1465,6 +1469,8 @@ pub fn starts_with<P: AsRef<Path>>(&self, base: P) -> bool {
/// Determines whether `child` is a suffix of `self`. /// Determines whether `child` is a suffix of `self`.
/// ///
/// Only considers whole path components to match.
///
/// # Examples /// # Examples
/// ///
/// ``` /// ```
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册