Skip to content

Commit 4070833

Browse files
committed
Implemented Path::ends_with
1 parent 5235cd5 commit 4070833

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/path/path.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,26 @@ impl Path {
124124
self.inner.display()
125125
}
126126

127+
/// Determines whether `child` is a suffix of `self`.
128+
///
129+
/// Only considers whole path components to match.
130+
///
131+
/// # Examples
132+
///
133+
/// ```
134+
/// use async_std::path::Path;
135+
///
136+
/// let path = Path::new("/etc/passwd");
137+
///
138+
/// assert!(path.ends_with("passwd"));
139+
/// ```
140+
pub fn ends_with<P: AsRef<Path>>(&self, child: P) -> bool
141+
where
142+
P: std::convert::AsRef<std::path::Path>,
143+
{
144+
self.inner.ends_with(child)
145+
}
146+
127147
/// Returns `true` if the path points at an existing entity.
128148
///
129149
/// This function will traverse symbolic links to query information about the

0 commit comments

Comments
 (0)