Trait std::os::unix::ffi::OsStrExt1.0.0 [] [src]

pub trait OsStrExt {
    fn from_bytes(slice: &[u8]) -> &Self;
fn as_bytes(&self) -> &[u8]; }
This is supported on Unix only.

Unix-specific extensions to OsStr.

Required Methods

Important traits for &'a mut I

This is supported on Unix only.

Creates an OsStr from a byte slice.

Examples

use std::ffi::OsStr;
use std::os::unix::ffi::OsStrExt;

let bytes = b"foo";
let os_str = OsStr::from_bytes(bytes);
assert_eq!(os_str.to_str(), Some("foo"));Run
Important traits for &'a [u8]

This is supported on Unix only.

Gets the underlying byte view of the OsStr slice.

Examples

use std::ffi::OsStr;
use std::os::unix::ffi::OsStrExt;

let mut os_str = OsStr::new("foo");
let bytes = os_str.as_bytes();
assert_eq!(bytes, b"foo");Run

Implementors