about summary refs log tree commit diff
path: root/src/libstd/sys
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2020-04-09 00:11:27 +0000
committerbors <bors@rust-lang.org>2020-04-09 00:11:27 +0000
commitd249d756374737eb014079901ac132f1e1ed905e (patch)
treee40a76a168a79ea3db20a0671e7367756dbc93a3 /src/libstd/sys
parent1edcfc83c6a08ddc5e63fc652b149baea0236e7c (diff)
parent5848209b64ad3403c155bc884f25500b178a5610 (diff)
downloadrust-d249d756374737eb014079901ac132f1e1ed905e.tar.gz
rust-d249d756374737eb014079901ac132f1e1ed905e.zip
Auto merge of #70936 - Dylan-DPC:rollup-2ng3e5h, r=Dylan-DPC
Rollup of 7 pull requests

Successful merges:

 - #70134 (add basic support of OsStrExt for HermitCore)
 - #70565 (Add inline attributes for functions used in the query system)
 - #70828 (rustdoc: Don't try to load source files from external crates)
 - #70870 (Fix abuses of tykind::err)
 - #70906 (Suggest move for closures and async blocks in more cases.)
 - #70912 (Do not suggest adding type param when `use` is already suggested)
 - #70930 (add tracking issue to `VecDeque::make_contiguous`)

Failed merges:

r? @ghost
Diffstat (limited to 'src/libstd/sys')
-rw-r--r--src/libstd/sys/hermit/ext/ffi.rs38
-rw-r--r--src/libstd/sys/hermit/ext/mod.rs14
-rw-r--r--src/libstd/sys/hermit/mod.rs1
3 files changed, 53 insertions, 0 deletions
diff --git a/src/libstd/sys/hermit/ext/ffi.rs b/src/libstd/sys/hermit/ext/ffi.rs
new file mode 100644
index 00000000000..07b59a02556
--- /dev/null
+++ b/src/libstd/sys/hermit/ext/ffi.rs
@@ -0,0 +1,38 @@
+//! HermitCore-specific extension to the primitives in the `std::ffi` module
+//!
+//! # Examples
+//!
+//! ```
+//! use std::ffi::OsString;
+//! use std::os::hermit::ffi::OsStringExt;
+//!
+//! let bytes = b"foo".to_vec();
+//!
+//! // OsStringExt::from_vec
+//! let os_string = OsString::from_vec(bytes);
+//! assert_eq!(os_string.to_str(), Some("foo"));
+//!
+//! // OsStringExt::into_vec
+//! let bytes = os_string.into_vec();
+//! assert_eq!(bytes, b"foo");
+//! ```
+//!
+//! ```
+//! use std::ffi::OsStr;
+//! use std::os::hermit::ffi::OsStrExt;
+//!
+//! let bytes = b"foo";
+//!
+//! // OsStrExt::from_bytes
+//! let os_str = OsStr::from_bytes(bytes);
+//! assert_eq!(os_str.to_str(), Some("foo"));
+//!
+//! // OsStrExt::as_bytes
+//! let bytes = os_str.as_bytes();
+//! assert_eq!(bytes, b"foo");
+//! ```
+
+#![stable(feature = "rust1", since = "1.0.0")]
+
+#[stable(feature = "rust1", since = "1.0.0")]
+pub use crate::sys_common::os_str_bytes::*;
diff --git a/src/libstd/sys/hermit/ext/mod.rs b/src/libstd/sys/hermit/ext/mod.rs
new file mode 100644
index 00000000000..ea87d0ad2c9
--- /dev/null
+++ b/src/libstd/sys/hermit/ext/mod.rs
@@ -0,0 +1,14 @@
+#![stable(feature = "rust1", since = "1.0.0")]
+#![allow(missing_docs)]
+
+pub mod ffi;
+
+/// A prelude for conveniently writing platform-specific code.
+///
+/// Includes all extension traits, and some important type definitions.
+#[stable(feature = "rust1", since = "1.0.0")]
+pub mod prelude {
+    #[doc(no_inline)]
+    #[stable(feature = "rust1", since = "1.0.0")]
+    pub use super::ffi::{OsStrExt, OsStringExt};
+}
diff --git a/src/libstd/sys/hermit/mod.rs b/src/libstd/sys/hermit/mod.rs
index 6736d964e52..f739df88ea6 100644
--- a/src/libstd/sys/hermit/mod.rs
+++ b/src/libstd/sys/hermit/mod.rs
@@ -21,6 +21,7 @@ pub mod args;
 pub mod cmath;
 pub mod condvar;
 pub mod env;
+pub mod ext;
 pub mod fast_thread_local;
 pub mod fd;
 pub mod fs;