Skip to content

Rollup of 10 pull requests #131722

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Changes from 2 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
e904761
Use environment variables instead of command line arguments for merge…
GuillaumeGomez Oct 1, 2024
3025513
Implemented FromStr for CString and TryFrom<CString> for String
YohDeadfall Sep 20, 2024
5fef462
Add 1.82 release notes
Mark-Simulacrum Oct 2, 2024
2bd0d07
Expand set_ptr_value / with_metadata_of docs
197g Oct 6, 2024
005a629
re-sync with latest tracking issue changes
Mark-Simulacrum Oct 7, 2024
cae29b2
Import another update
Mark-Simulacrum Oct 12, 2024
276d112
Add stabilized APIs
Mark-Simulacrum Oct 12, 2024
5b2985f
Add explicit link to PR
Mark-Simulacrum Oct 12, 2024
c128b4c
Fix typo thing->thin referring to pointer
197g Oct 13, 2024
feecfaa
Fix bug where `option_env!` would return `None` when env var is prese…
beetrees Mar 18, 2024
b6b6c12
Update lint message for ABI not supported
tdittr Oct 14, 2024
c6e1fbf
Fix up-to-date checking for run-make tests
Zalathar Oct 14, 2024
eb6062c
Resolved python deprecation warning in publish_toolstate.py
alex Oct 14, 2024
b73e613
De-duplicate and move `adjust_nan` to `InterpCx`
eduardosm Oct 14, 2024
4e438f7
Fix two const-hacks
GKFX Oct 14, 2024
029a881
Make some float methods unstable `const fn`
eduardosm Oct 14, 2024
1a39c53
Rollup merge of #122670 - beetrees:non-unicode-option-env-error, r=co…
compiler-errors Oct 15, 2024
62ea2b9
Rollup merge of #130568 - eduardosm:const-float-methods, r=RalfJung,t…
compiler-errors Oct 15, 2024
aeffde2
Rollup merge of #130608 - YohDeadfall:cstr-from-into-str, r=workingju…
compiler-errors Oct 15, 2024
dae9ca7
Rollup merge of #131095 - GuillaumeGomez:switch-to-env-variables, r=n…
compiler-errors Oct 15, 2024
cab3439
Rollup merge of #131137 - Mark-Simulacrum:relnotes, r=cuviper
compiler-errors Oct 15, 2024
4e7a9ff
Rollup merge of #131339 - HeroicKatora:set_ptr_value-documentation, r…
compiler-errors Oct 15, 2024
619b123
Rollup merge of #131675 - tdittr:update-unsupported-abi-message, r=co…
compiler-errors Oct 15, 2024
71f2254
Rollup merge of #131681 - Zalathar:fix-run-make-stamp, r=jieyouxu
compiler-errors Oct 15, 2024
af762b8
Rollup merge of #131703 - alex:patch-1, r=Kobzol
compiler-errors Oct 15, 2024
08c12fa
Rollup merge of #131706 - GKFX:fix-const-hacks, r=tgross35
compiler-errors Oct 15, 2024
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
26 changes: 25 additions & 1 deletion library/alloc/src/ffi/c_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use core::borrow::Borrow;
use core::ffi::{CStr, c_char};
use core::num::NonZero;
use core::slice::memchr;
use core::str::{self, Utf8Error};
use core::str::{self, FromStr, Utf8Error};
use core::{fmt, mem, ops, ptr, slice};

use crate::borrow::{Cow, ToOwned};
Expand Down Expand Up @@ -817,6 +817,30 @@ impl From<Vec<NonZero<u8>>> for CString {
}
}

impl FromStr for CString {
type Err = NulError;

/// Converts a string `s` into a [`CString`].
///
/// This method is equivalent to [`CString::new`].
#[inline]
fn from_str(s: &str) -> Result<Self, Self::Err> {
Self::new(s)
}
}

impl TryFrom<CString> for String {
type Error = IntoStringError;

/// Converts a [`CString`] into a [`String`] if it contains valid UTF-8 data.
///
/// This method is equivalent to [`CString::into_string`].
#[inline]
fn try_from(value: CString) -> Result<Self, Self::Error> {
value.into_string()
}
}

#[cfg(not(test))]
#[stable(feature = "more_box_slice_clone", since = "1.29.0")]
impl Clone for Box<CStr> {
Expand Down