Skip to content

Commit 474c6a1

Browse files
committed
constify From impls for the Cow::Borrowed variant
1 parent d2acb42 commit 474c6a1

File tree

4 files changed

+10
-5
lines changed

4 files changed

+10
-5
lines changed

library/alloc/src/bstr.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,8 @@ impl Clone for Box<ByteStr> {
598598
}
599599

600600
#[unstable(feature = "bstr", issue = "134915")]
601-
impl<'a> From<&'a ByteStr> for Cow<'a, ByteStr> {
601+
#[rustc_const_unstable(feature = "const_convert", issue = "143773")]
602+
impl<'a> const From<&'a ByteStr> for Cow<'a, ByteStr> {
602603
#[inline]
603604
fn from(s: &'a ByteStr) -> Self {
604605
Cow::Borrowed(s)

library/alloc/src/ffi/c_str.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -878,7 +878,8 @@ impl<'a> From<CString> for Cow<'a, CStr> {
878878
}
879879

880880
#[stable(feature = "cow_from_cstr", since = "1.28.0")]
881-
impl<'a> From<&'a CStr> for Cow<'a, CStr> {
881+
#[rustc_const_unstable(feature = "const_convert", issue = "143773")]
882+
impl<'a> const From<&'a CStr> for Cow<'a, CStr> {
882883
/// Converts a [`CStr`] into a borrowed [`Cow`] without copying or allocating.
883884
#[inline]
884885
fn from(s: &'a CStr) -> Cow<'a, CStr> {

library/alloc/src/string.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3096,7 +3096,8 @@ impl<'a> From<Cow<'a, str>> for String {
30963096

30973097
#[cfg(not(no_global_oom_handling))]
30983098
#[stable(feature = "rust1", since = "1.0.0")]
3099-
impl<'a> From<&'a str> for Cow<'a, str> {
3099+
#[rustc_const_unstable(feature = "const_convert", issue = "143773")]
3100+
impl<'a> const From<&'a str> for Cow<'a, str> {
31003101
/// Converts a string slice into a [`Borrowed`] variant.
31013102
/// No heap allocation is performed, and the string
31023103
/// is not copied.

library/alloc/src/vec/cow.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ use super::Vec;
22
use crate::borrow::Cow;
33

44
#[stable(feature = "cow_from_vec", since = "1.8.0")]
5-
impl<'a, T: Clone> From<&'a [T]> for Cow<'a, [T]> {
5+
#[rustc_const_unstable(feature = "const_convert", issue = "143773")]
6+
impl<'a, T: Clone> const From<&'a [T]> for Cow<'a, [T]> {
67
/// Creates a [`Borrowed`] variant of [`Cow`]
78
/// from a slice.
89
///
@@ -15,7 +16,8 @@ impl<'a, T: Clone> From<&'a [T]> for Cow<'a, [T]> {
1516
}
1617

1718
#[stable(feature = "cow_from_array_ref", since = "1.77.0")]
18-
impl<'a, T: Clone, const N: usize> From<&'a [T; N]> for Cow<'a, [T]> {
19+
#[rustc_const_unstable(feature = "const_convert", issue = "143773")]
20+
impl<'a, T: Clone, const N: usize> const From<&'a [T; N]> for Cow<'a, [T]> {
1921
/// Creates a [`Borrowed`] variant of [`Cow`]
2022
/// from a reference to an array.
2123
///

0 commit comments

Comments
 (0)