]> git.proxmox.com Git - rustc.git/blame - src/libstd/sys/unix/ext/ffi.rs
New upstream version 1.46.0+dfsg1
[rustc.git] / src / libstd / sys / unix / ext / ffi.rs
CommitLineData
d9579d0f 1//! Unix-specific extension to the primitives in the `std::ffi` module
532ac7d7
XL
2//!
3//! # Examples
4//!
5//! ```
6//! use std::ffi::OsString;
7//! use std::os::unix::ffi::OsStringExt;
8//!
9//! let bytes = b"foo".to_vec();
10//!
11//! // OsStringExt::from_vec
12//! let os_string = OsString::from_vec(bytes);
13//! assert_eq!(os_string.to_str(), Some("foo"));
14//!
15//! // OsStringExt::into_vec
16//! let bytes = os_string.into_vec();
17//! assert_eq!(bytes, b"foo");
18//! ```
19//!
20//! ```
21//! use std::ffi::OsStr;
22//! use std::os::unix::ffi::OsStrExt;
23//!
24//! let bytes = b"foo";
25//!
26//! // OsStrExt::from_bytes
27//! let os_str = OsStr::from_bytes(bytes);
28//! assert_eq!(os_str.to_str(), Some("foo"));
29//!
30//! // OsStrExt::as_bytes
31//! let bytes = os_str.as_bytes();
32//! assert_eq!(bytes, b"foo");
33//! ```
d9579d0f
AL
34
35#![stable(feature = "rust1", since = "1.0.0")]
36
d9579d0f 37#[stable(feature = "rust1", since = "1.0.0")]
532ac7d7 38pub use crate::sys_common::os_str_bytes::*;