@@ -63,14 +63,16 @@ impl ByteStr {
6363 /// ```
6464 #[ inline]
6565 #[ unstable( feature = "bstr" , issue = "134915" ) ]
66- pub fn new < B : ?Sized + AsRef < [ u8 ] > > ( bytes : & B ) -> & Self {
66+ #[ rustc_const_unstable( feature = "const_convert" , issue = "143773" ) ]
67+ pub const fn new < B : ?Sized + [ const ] AsRef < [ u8 ] > > ( bytes : & B ) -> & Self {
6768 ByteStr :: from_bytes ( bytes. as_ref ( ) )
6869 }
6970
7071 #[ doc( hidden) ]
7172 #[ unstable( feature = "bstr_internals" , issue = "none" ) ]
7273 #[ inline]
73- pub fn from_bytes ( slice : & [ u8 ] ) -> & Self {
74+ #[ rustc_const_unstable( feature = "bstr_internals" , issue = "none" ) ]
75+ pub const fn from_bytes ( slice : & [ u8 ] ) -> & Self {
7476 // SAFETY: `ByteStr` is a transparent wrapper around `[u8]`, so we can turn a reference to
7577 // the wrapped type into a reference to the wrapper type.
7678 unsafe { & * ( slice as * const [ u8 ] as * const Self ) }
@@ -79,7 +81,8 @@ impl ByteStr {
7981 #[ doc( hidden) ]
8082 #[ unstable( feature = "bstr_internals" , issue = "none" ) ]
8183 #[ inline]
82- pub fn from_bytes_mut ( slice : & mut [ u8 ] ) -> & mut Self {
84+ #[ rustc_const_unstable( feature = "bstr_internals" , issue = "none" ) ]
85+ pub const fn from_bytes_mut ( slice : & mut [ u8 ] ) -> & mut Self {
8386 // SAFETY: `ByteStr` is a transparent wrapper around `[u8]`, so we can turn a reference to
8487 // the wrapped type into a reference to the wrapper type.
8588 unsafe { & mut * ( slice as * mut [ u8 ] as * mut Self ) }
@@ -88,20 +91,23 @@ impl ByteStr {
8891 #[ doc( hidden) ]
8992 #[ unstable( feature = "bstr_internals" , issue = "none" ) ]
9093 #[ inline]
91- pub fn as_bytes ( & self ) -> & [ u8 ] {
94+ #[ rustc_const_unstable( feature = "bstr_internals" , issue = "none" ) ]
95+ pub const fn as_bytes ( & self ) -> & [ u8 ] {
9296 & self . 0
9397 }
9498
9599 #[ doc( hidden) ]
96100 #[ unstable( feature = "bstr_internals" , issue = "none" ) ]
97101 #[ inline]
98- pub fn as_bytes_mut ( & mut self ) -> & mut [ u8 ] {
102+ #[ rustc_const_unstable( feature = "bstr_internals" , issue = "none" ) ]
103+ pub const fn as_bytes_mut ( & mut self ) -> & mut [ u8 ] {
99104 & mut self . 0
100105 }
101106}
102107
103108#[ unstable( feature = "bstr" , issue = "134915" ) ]
104- impl Deref for ByteStr {
109+ #[ rustc_const_unstable( feature = "const_convert" , issue = "143773" ) ]
110+ impl const Deref for ByteStr {
105111 type Target = [ u8 ] ;
106112
107113 #[ inline]
@@ -111,7 +117,8 @@ impl Deref for ByteStr {
111117}
112118
113119#[ unstable( feature = "bstr" , issue = "134915" ) ]
114- impl DerefMut for ByteStr {
120+ #[ rustc_const_unstable( feature = "const_convert" , issue = "143773" ) ]
121+ impl const DerefMut for ByteStr {
115122 #[ inline]
116123 fn deref_mut ( & mut self ) -> & mut [ u8 ] {
117124 & mut self . 0
@@ -185,15 +192,17 @@ impl fmt::Display for ByteStr {
185192}
186193
187194#[ unstable( feature = "bstr" , issue = "134915" ) ]
188- impl AsRef < [ u8 ] > for ByteStr {
195+ #[ rustc_const_unstable( feature = "const_convert" , issue = "143773" ) ]
196+ impl const AsRef < [ u8 ] > for ByteStr {
189197 #[ inline]
190198 fn as_ref ( & self ) -> & [ u8 ] {
191199 & self . 0
192200 }
193201}
194202
195203#[ unstable( feature = "bstr" , issue = "134915" ) ]
196- impl AsRef < ByteStr > for ByteStr {
204+ #[ rustc_const_unstable( feature = "const_convert" , issue = "143773" ) ]
205+ impl const AsRef < ByteStr > for ByteStr {
197206 #[ inline]
198207 fn as_ref ( & self ) -> & ByteStr {
199208 self
@@ -203,15 +212,17 @@ impl AsRef<ByteStr> for ByteStr {
203212// `impl AsRef<ByteStr> for [u8]` omitted to avoid widespread inference failures
204213
205214#[ unstable( feature = "bstr" , issue = "134915" ) ]
206- impl AsRef < ByteStr > for str {
215+ #[ rustc_const_unstable( feature = "const_convert" , issue = "143773" ) ]
216+ impl const AsRef < ByteStr > for str {
207217 #[ inline]
208218 fn as_ref ( & self ) -> & ByteStr {
209219 ByteStr :: new ( self )
210220 }
211221}
212222
213223#[ unstable( feature = "bstr" , issue = "134915" ) ]
214- impl AsMut < [ u8 ] > for ByteStr {
224+ #[ rustc_const_unstable( feature = "const_convert" , issue = "143773" ) ]
225+ impl const AsMut < [ u8 ] > for ByteStr {
215226 #[ inline]
216227 fn as_mut ( & mut self ) -> & mut [ u8 ] {
217228 & mut self . 0
@@ -225,7 +236,8 @@ impl AsMut<[u8]> for ByteStr {
225236// `impl Borrow<ByteStr> for str` omitted to avoid widespread inference failures
226237
227238#[ unstable( feature = "bstr" , issue = "134915" ) ]
228- impl Borrow < [ u8 ] > for ByteStr {
239+ #[ rustc_const_unstable( feature = "const_convert" , issue = "143773" ) ]
240+ impl const Borrow < [ u8 ] > for ByteStr {
229241 #[ inline]
230242 fn borrow ( & self ) -> & [ u8 ] {
231243 & self . 0
@@ -235,7 +247,8 @@ impl Borrow<[u8]> for ByteStr {
235247// `impl BorrowMut<ByteStr> for [u8]` omitted to avoid widespread inference failures
236248
237249#[ unstable( feature = "bstr" , issue = "134915" ) ]
238- impl BorrowMut < [ u8 ] > for ByteStr {
250+ #[ rustc_const_unstable( feature = "const_convert" , issue = "143773" ) ]
251+ impl const BorrowMut < [ u8 ] > for ByteStr {
239252 #[ inline]
240253 fn borrow_mut ( & mut self ) -> & mut [ u8 ] {
241254 & mut self . 0
@@ -303,7 +316,8 @@ impl<'a> Default for &'a mut ByteStr {
303316// }
304317
305318#[ unstable( feature = "bstr" , issue = "134915" ) ]
306- impl < ' a > TryFrom < & ' a ByteStr > for & ' a str {
319+ #[ rustc_const_unstable( feature = "const_convert" , issue = "143773" ) ]
320+ impl < ' a > const TryFrom < & ' a ByteStr > for & ' a str {
307321 type Error = crate :: str:: Utf8Error ;
308322
309323 #[ inline]
@@ -313,7 +327,8 @@ impl<'a> TryFrom<&'a ByteStr> for &'a str {
313327}
314328
315329#[ unstable( feature = "bstr" , issue = "134915" ) ]
316- impl < ' a > TryFrom < & ' a mut ByteStr > for & ' a mut str {
330+ #[ rustc_const_unstable( feature = "const_convert" , issue = "143773" ) ]
331+ impl < ' a > const TryFrom < & ' a mut ByteStr > for & ' a mut str {
317332 type Error = crate :: str:: Utf8Error ;
318333
319334 #[ inline]
0 commit comments