@@ -251,6 +251,14 @@ impl Hash for OsString {
251251
252252impl OsStr {
253253 /// Coerces into an `OsStr` slice.
254+ ///
255+ /// # Examples
256+ ///
257+ /// ```
258+ /// use std::ffi::OsStr;
259+ ///
260+ /// let os_str = OsStr::new("foo");
261+ /// ```
254262 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
255263 pub fn new < S : AsRef < OsStr > + ?Sized > ( s : & S ) -> & OsStr {
256264 s. as_ref ( )
@@ -283,6 +291,18 @@ impl OsStr {
283291 }
284292
285293 /// Checks whether the `OsStr` is empty.
294+ ///
295+ /// # Examples
296+ ///
297+ /// ```
298+ /// use std::ffi::OsStr;
299+ ///
300+ /// let os_str = OsStr::new("");
301+ /// assert!(os_str.is_empty());
302+ ///
303+ /// let os_str = OsStr::new("foo");
304+ /// assert!(!os_str.is_empty());
305+ /// ```
286306 #[ stable( feature = "osstring_simple_functions" , since = "1.9.0" ) ]
287307 pub fn is_empty ( & self ) -> bool {
288308 self . inner . inner . is_empty ( )
@@ -296,6 +316,18 @@ impl OsStr {
296316 /// other methods like `OsString::with_capacity` to avoid reallocations.
297317 ///
298318 /// See `OsStr` introduction for more information about encoding.
319+ ///
320+ /// # Examples
321+ ///
322+ /// ```
323+ /// use std::ffi::OsStr;
324+ ///
325+ /// let os_str = OsStr::new("");
326+ /// assert_eq!(os_str.len(), 0);
327+ ///
328+ /// let os_str = OsStr::new("foo");
329+ /// assert_eq!(os_str.len(), 3);
330+ /// ```
299331 #[ stable( feature = "osstring_simple_functions" , since = "1.9.0" ) ]
300332 pub fn len ( & self ) -> usize {
301333 self . inner . inner . len ( )
0 commit comments