From 9a7b789c3717146ca3ce3fca1eb23fa3a239f0fb Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Sun, 12 Mar 2017 15:04:32 -0400 Subject: [PATCH] Add doc example for `OsStr::to_os_string`. --- src/libstd/ffi/os_str.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/libstd/ffi/os_str.rs b/src/libstd/ffi/os_str.rs index 41bdd9c51d45..3914f398961e 100644 --- a/src/libstd/ffi/os_str.rs +++ b/src/libstd/ffi/os_str.rs @@ -398,6 +398,16 @@ impl OsStr { /// Copies the slice into an owned [`OsString`]. /// /// [`OsString`]: struct.OsString.html + /// + /// # Examples + /// + /// ``` + /// use std::ffi::{OsStr, OsString}; + /// + /// let os_str = OsStr::new("foo"); + /// let os_string = os_str.to_os_string(); + /// assert_eq!(os_string, OsString::from("foo")); + /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub fn to_os_string(&self) -> OsString { OsString { inner: self.inner.to_owned() }