Skip to content

Commit

Permalink
docs(std): add docs for cof_from_cstr impls
Browse files Browse the repository at this point in the history
  • Loading branch information
notriddle committed Sep 15, 2021
1 parent ef44452 commit cc7929b
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions library/std/src/ffi/c_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -915,6 +915,7 @@ impl From<CString> for Box<CStr> {

#[stable(feature = "cow_from_cstr", since = "1.28.0")]
impl<'a> From<CString> for Cow<'a, CStr> {
/// Converts a [`CString`] into an owned [`Cow`] without copying or allocating.
#[inline]
fn from(s: CString) -> Cow<'a, CStr> {
Cow::Owned(s)
Expand All @@ -923,6 +924,7 @@ impl<'a> From<CString> for Cow<'a, CStr> {

#[stable(feature = "cow_from_cstr", since = "1.28.0")]
impl<'a> From<&'a CStr> for Cow<'a, CStr> {
/// Converts a [`CStr`] into a borrowed [`Cow`] without copying or allocating.
#[inline]
fn from(s: &'a CStr) -> Cow<'a, CStr> {
Cow::Borrowed(s)
Expand All @@ -931,6 +933,7 @@ impl<'a> From<&'a CStr> for Cow<'a, CStr> {

#[stable(feature = "cow_from_cstr", since = "1.28.0")]
impl<'a> From<&'a CString> for Cow<'a, CStr> {
/// Converts a `&`[`CString`] into a borrowed [`Cow`] without copying or allocating.
#[inline]
fn from(s: &'a CString) -> Cow<'a, CStr> {
Cow::Borrowed(s.as_c_str())
Expand Down

0 comments on commit cc7929b

Please sign in to comment.