Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/doc/unstable-book/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
- [alloc_system](alloc-system.md)
- [allocator](allocator.md)
- [allow_internal_unstable](allow-internal-unstable.md)
- [as_c_str](as-c-str.md)
- [as_unsafe_cell](as-unsafe-cell.md)
- [ascii_ctype](ascii-ctype.md)
- [asm](asm.md)
Expand Down
8 changes: 8 additions & 0 deletions src/doc/unstable-book/src/as-c-str.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# `as_c_str`

The tracking issue for this feature is: [#40380]

[#40380]: https://github.com/rust-lang/rust/issues/40380

------------------------

6 changes: 6 additions & 0 deletions src/libstd/ffi/c_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,12 @@ impl CString {
&self.inner
}

/// Extracts a `CStr` slice containing the entire string.
#[unstable(feature = "as_c_str", issue = "40380")]
pub fn as_c_str(&self) -> &CStr {
&*self
}

/// Converts this `CString` into a boxed `CStr`.
#[unstable(feature = "into_boxed_c_str", issue = "40380")]
pub fn into_boxed_c_str(self) -> Box<CStr> {
Expand Down