Add as_c_str.
This commit is contained in:
parent
44855a4cef
commit
68909b0ec0
@ -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)
|
||||
|
8
src/doc/unstable-book/src/as-c-str.md
Normal file
8
src/doc/unstable-book/src/as-c-str.md
Normal file
@ -0,0 +1,8 @@
|
||||
# `as_c_str`
|
||||
|
||||
The tracking issue for this feature is: [#40380]
|
||||
|
||||
[#40380]: https://github.com/rust-lang/rust/issues/40380
|
||||
|
||||
------------------------
|
||||
|
@ -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> {
|
||||
|
Loading…
Reference in New Issue
Block a user