From 40708334820cf9cfcaf164d3a14cc6746c070bab Mon Sep 17 00:00:00 2001 From: Wouter Geraedts Date: Sun, 13 Oct 2019 18:58:36 +0200 Subject: [PATCH] Implemented Path::ends_with --- src/path/path.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/path/path.rs b/src/path/path.rs index dcda43a..fffe4c1 100644 --- a/src/path/path.rs +++ b/src/path/path.rs @@ -124,6 +124,26 @@ impl Path { self.inner.display() } + /// Determines whether `child` is a suffix of `self`. + /// + /// Only considers whole path components to match. + /// + /// # Examples + /// + /// ``` + /// use async_std::path::Path; + /// + /// let path = Path::new("/etc/passwd"); + /// + /// assert!(path.ends_with("passwd")); + /// ``` + pub fn ends_with>(&self, child: P) -> bool + where + P: std::convert::AsRef, + { + self.inner.ends_with(child) + } + /// Returns `true` if the path points at an existing entity. /// /// This function will traverse symbolic links to query information about the