about summary refs log tree commit diff
path: root/library/std/src/sys/unix/os_str.rs
diff options
context:
space:
mode:
Diffstat (limited to 'library/std/src/sys/unix/os_str.rs')
-rw-r--r--library/std/src/sys/unix/os_str.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/library/std/src/sys/unix/os_str.rs b/library/std/src/sys/unix/os_str.rs
index 142fcb9ed0b..f7333fd5a1f 100644
--- a/library/std/src/sys/unix/os_str.rs
+++ b/library/std/src/sys/unix/os_str.rs
@@ -207,8 +207,8 @@ impl Slice {
         unsafe { Slice::from_os_str_bytes_unchecked(s.as_bytes()) }
     }
 
-    pub fn to_str(&self) -> Option<&str> {
-        str::from_utf8(&self.inner).ok()
+    pub fn to_str(&self) -> Result<&str, crate::str::Utf8Error> {
+        str::from_utf8(&self.inner)
     }
 
     pub fn to_string_lossy(&self) -> Cow<'_, str> {