pub trait OsStrExt {
fn from_bytes(slice: &[u8]) -> &Self;
fn as_bytes(&self) -> &[u8];
}
Unix-specific extensions to OsStr.
fn from_bytes(slice: &[u8]) -> &SelfCreates an OsStr from a byte slice.
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")); fn as_bytes(&self) -> &[u8]Gets the underlying byte view of the OsStr slice.
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"); impl OsStrExt for OsStr
© 2010 The Rust Project Developers
Licensed under the Apache License, Version 2.0 or the MIT license, at your option.
https://doc.rust-lang.org/std/os/unix/ffi/trait.OsStrExt.html