]> git.proxmox.com Git - rustc.git/blob - src/libstd/sys/hermit/ext/ffi.rs
New upstream version 1.44.1+dfsg1
[rustc.git] / src / libstd / sys / hermit / ext / ffi.rs
1 //! HermitCore-specific extension to the primitives in the `std::ffi` module
2 //!
3 //! # Examples
4 //!
5 //! ```
6 //! use std::ffi::OsString;
7 //! use std::os::hermit::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::hermit::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 //! ```
34
35 #![stable(feature = "rust1", since = "1.0.0")]
36
37 #[stable(feature = "rust1", since = "1.0.0")]
38 pub use crate::sys_common::os_str_bytes::*;