Skip to content

Commit 3baf19f

Browse files
committed
Add std::ffi::c_str module
1 parent 6162f6f commit 3baf19f

File tree

7 files changed

+71
-11
lines changed

7 files changed

+71
-11
lines changed

library/alloc/src/ffi/c_str.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! [`CString`] and its related types.
2+
13
#[cfg(test)]
24
mod tests;
35

library/alloc/src/ffi/mod.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,13 @@
8080
8181
#![stable(feature = "alloc_ffi", since = "1.64.0")]
8282

83+
#[doc(no_inline)]
8384
#[stable(feature = "alloc_c_string", since = "1.64.0")]
84-
pub use self::c_str::FromVecWithNulError;
85+
pub use self::c_str::{FromVecWithNulError, IntoStringError, NulError};
86+
87+
#[doc(inline)]
8588
#[stable(feature = "alloc_c_string", since = "1.64.0")]
86-
pub use self::c_str::{CString, IntoStringError, NulError};
89+
pub use self::c_str::CString;
8790

88-
mod c_str;
91+
#[unstable(feature = "c_str_module", issue = "112134")]
92+
pub mod c_str;

library/core/src/ffi/c_str.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! [`CStr`] and its related types.
2+
13
use crate::cmp::Ordering;
24
use crate::error::Error;
35
use crate::ffi::c_char;
@@ -25,8 +27,8 @@ use crate::str;
2527
/// functions may leverage the unsafe [`CStr::from_ptr`] constructor to provide
2628
/// a safe interface to other consumers.
2729
///
28-
/// [`CString`]: ../../std/ffi/struct.CString.html
29-
/// [`String`]: ../../std/string/struct.String.html
30+
/// [`CString`]: ../../../std/ffi/c_str/struct.CString.html
31+
/// [`String`]: ../../../std/string/struct.String.html
3032
///
3133
/// # Examples
3234
///

library/core/src/ffi/mod.rs

+12-2
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,20 @@ use crate::marker::PhantomData;
1414
use crate::num::*;
1515
use crate::ops::{Deref, DerefMut};
1616

17+
#[doc(no_inline)]
1718
#[stable(feature = "core_c_str", since = "1.64.0")]
18-
pub use self::c_str::{CStr, FromBytesUntilNulError, FromBytesWithNulError};
19+
pub use self::c_str::FromBytesWithNulError;
1920

20-
mod c_str;
21+
#[doc(no_inline)]
22+
#[stable(feature = "cstr_from_bytes_until_nul", since = "1.69.0")]
23+
pub use self::c_str::FromBytesUntilNulError;
24+
25+
#[doc(inline)]
26+
#[stable(feature = "core_c_str", since = "1.64.0")]
27+
pub use self::c_str::CStr;
28+
29+
#[unstable(feature = "c_str_module", issue = "112134")]
30+
pub mod c_str;
2131

2232
macro_rules! type_alias_no_nz {
2333
{

library/std/src/ffi/c_str.rs

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//! [`CStr`], [`CString`], and related types.
2+
3+
#[stable(feature = "rust1", since = "1.0.0")]
4+
pub use core::ffi::c_str::CStr;
5+
6+
#[stable(feature = "cstr_from_bytes", since = "1.10.0")]
7+
pub use core::ffi::c_str::FromBytesWithNulError;
8+
9+
#[stable(feature = "cstr_from_bytes_until_nul", since = "1.69.0")]
10+
pub use core::ffi::c_str::FromBytesUntilNulError;
11+
12+
#[stable(feature = "rust1", since = "1.0.0")]
13+
pub use alloc::ffi::c_str::{CString, NulError};
14+
15+
#[stable(feature = "cstring_from_vec_with_nul", since = "1.58.0")]
16+
pub use alloc::ffi::c_str::FromVecWithNulError;
17+
18+
#[stable(feature = "cstring_into", since = "1.7.0")]
19+
pub use alloc::ffi::c_str::IntoStringError;

library/std/src/ffi/mod.rs

+26-4
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,32 @@
154154
155155
#![stable(feature = "rust1", since = "1.0.0")]
156156

157-
#[stable(feature = "alloc_c_string", since = "1.64.0")]
158-
pub use alloc::ffi::{CString, FromVecWithNulError, IntoStringError, NulError};
159-
#[stable(feature = "core_c_str", since = "1.64.0")]
160-
pub use core::ffi::{CStr, FromBytesWithNulError};
157+
#[unstable(feature = "c_str_module", issue = "112134")]
158+
pub mod c_str;
159+
160+
#[doc(inline)]
161+
#[stable(feature = "rust1", since = "1.0.0")]
162+
pub use self::c_str::{CStr, CString};
163+
164+
#[doc(no_inline)]
165+
#[stable(feature = "cstr_from_bytes", since = "1.10.0")]
166+
pub use self::c_str::FromBytesWithNulError;
167+
168+
#[doc(no_inline)]
169+
#[stable(feature = "cstr_from_bytes_until_nul", since = "1.69.0")]
170+
pub use self::c_str::FromBytesUntilNulError;
171+
172+
#[doc(no_inline)]
173+
#[stable(feature = "rust1", since = "1.0.0")]
174+
pub use self::c_str::NulError;
175+
176+
#[doc(no_inline)]
177+
#[stable(feature = "cstring_from_vec_with_nul", since = "1.58.0")]
178+
pub use self::c_str::FromVecWithNulError;
179+
180+
#[doc(no_inline)]
181+
#[stable(feature = "cstring_into", since = "1.7.0")]
182+
pub use self::c_str::IntoStringError;
161183

162184
#[stable(feature = "rust1", since = "1.0.0")]
163185
pub use self::os_str::{OsStr, OsString};

library/std/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@
278278
//
279279
// Library features (core):
280280
// tidy-alphabetical-start
281+
#![feature(c_str_module)]
281282
#![feature(char_internals)]
282283
#![feature(core_intrinsics)]
283284
#![feature(duration_constants)]

0 commit comments

Comments
 (0)