From 32286b039cbd26ddd9d31326e2a362a862e3a5a8 Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Wed, 13 Feb 2019 14:26:34 +0100 Subject: [PATCH] tools/fs: add file_name_utf8_unchecked shortcut Signed-off-by: Wolfgang Bumiller --- src/tools/fs.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/tools/fs.rs b/src/tools/fs.rs index 25e04b33..f000bfac 100644 --- a/src/tools/fs.rs +++ b/src/tools/fs.rs @@ -66,6 +66,10 @@ impl ReadDirEntry { pub fn parent_fd(&self) -> RawFd { self.parent_fd } + + pub unsafe fn file_name_utf8_unchecked(&self) -> &str { + std::str::from_utf8_unchecked(self.file_name().to_bytes()) + } } // Since Tied implements Deref to U, a Tied already implements Iterator.