diff options
| author | ltdk <usr@ltdk.xyz> | 2025-08-11 19:36:20 -0400 |
|---|---|---|
| committer | ltdk <usr@ltdk.xyz> | 2025-09-01 21:38:26 -0400 |
| commit | 1c64d3e6d1fe6256cb11b8dd455ccad1b5f9848c (patch) | |
| tree | 88e2d32ae6ba2658a97f902eb925960f293a4e6e /library/std/src/path.rs | |
| parent | 41f2b6b39e7526a28d50ff6918dda6de48add5e4 (diff) | |
| download | rust-1c64d3e6d1fe6256cb11b8dd455ccad1b5f9848c.tar.gz rust-1c64d3e6d1fe6256cb11b8dd455ccad1b5f9848c.zip | |
Constify conversion traits
Diffstat (limited to 'library/std/src/path.rs')
| -rw-r--r-- | library/std/src/path.rs | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/library/std/src/path.rs b/library/std/src/path.rs index 470d300d2d9..5ccea1c972c 100644 --- a/library/std/src/path.rs +++ b/library/std/src/path.rs @@ -2264,11 +2264,13 @@ impl Path { /// assert_eq!(from_string, from_path); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - pub fn new<S: AsRef<OsStr> + ?Sized>(s: &S) -> &Path { + #[rustc_const_unstable(feature = "const_convert", issue = "143773")] + pub const fn new<S: [const] AsRef<OsStr> + ?Sized>(s: &S) -> &Path { unsafe { &*(s.as_ref() as *const OsStr as *const Path) } } - fn from_inner_mut(inner: &mut OsStr) -> &mut Path { + #[rustc_const_unstable(feature = "const_convert", issue = "143773")] + const fn from_inner_mut(inner: &mut OsStr) -> &mut Path { // SAFETY: Path is just a wrapper around OsStr, // therefore converting &mut OsStr to &mut Path is safe. unsafe { &mut *(inner as *mut OsStr as *mut Path) } @@ -3337,7 +3339,8 @@ unsafe impl CloneToUninit for Path { } #[stable(feature = "rust1", since = "1.0.0")] -impl AsRef<OsStr> for Path { +#[rustc_const_unstable(feature = "const_convert", issue = "143773")] +impl const AsRef<OsStr> for Path { #[inline] fn as_ref(&self) -> &OsStr { &self.inner @@ -3507,7 +3510,8 @@ impl Ord for Path { } #[stable(feature = "rust1", since = "1.0.0")] -impl AsRef<Path> for Path { +#[rustc_const_unstable(feature = "const_convert", issue = "143773")] +impl const AsRef<Path> for Path { #[inline] fn as_ref(&self) -> &Path { self @@ -3515,7 +3519,8 @@ impl AsRef<Path> for Path { } #[stable(feature = "rust1", since = "1.0.0")] -impl AsRef<Path> for OsStr { +#[rustc_const_unstable(feature = "const_convert", issue = "143773")] +impl const AsRef<Path> for OsStr { #[inline] fn as_ref(&self) -> &Path { Path::new(self) |
