Skip to content

Commit

Permalink
Rollup merge of rust-lang#88976 - notriddle:notriddle/cow-from-cstr-d…
Browse files Browse the repository at this point in the history
…ocs, r=Mark-Simulacrum

Clean up and add doc comments for CStr

CC rust-lang#51430
  • Loading branch information
Manishearth authored Sep 16, 2021
2 parents 5b6285e + cc7929b commit 06dbc28
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/rustc_expand/src/mbe/quoted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ pub(super) fn parse(
// this with just `span.edition()`. A
// `SyntaxContext::root()` from the current crate will
// have the edition of the current crate, and a
// `SyntaxxContext::root()` from a foreign crate will
// `SyntaxContext::root()` from a foreign crate will
// have the edition of that crate (which we manually
// retrieve via the `edition` parameter).
if span.ctxt() == SyntaxContext::root() {
Expand Down
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 06dbc28

Please sign in to comment.