@@ -198,7 +198,7 @@ impl str {
198
198
/// Basic usage:
199
199
///
200
200
/// ```
201
- /// use std::str;
201
+ /// #![feature(inherent_str_constructors)]
202
202
///
203
203
/// // some bytes, in a vector
204
204
/// let sparkle_heart = vec![240, 159, 146, 150];
@@ -207,13 +207,13 @@ impl str {
207
207
/// let sparkle_heart = str::from_utf8(&sparkle_heart)?;
208
208
///
209
209
/// assert_eq!("💖", sparkle_heart);
210
- /// # Ok::<_, str::Utf8Error>(())
210
+ /// # Ok::<_, std:: str::Utf8Error>(())
211
211
/// ```
212
212
///
213
213
/// Incorrect bytes:
214
214
///
215
215
/// ```
216
- /// use std::str;
216
+ /// #![feature(inherent_str_constructors)]
217
217
///
218
218
/// // some invalid bytes, in a vector
219
219
/// let sparkle_heart = vec![0, 159, 146, 150];
@@ -227,7 +227,7 @@ impl str {
227
227
/// A "stack allocated string":
228
228
///
229
229
/// ```
230
- /// use std::str;
230
+ /// #![feature(inherent_str_constructors)]
231
231
///
232
232
/// // some bytes, in a stack-allocated array
233
233
/// let sparkle_heart = [240, 159, 146, 150];
@@ -238,6 +238,7 @@ impl str {
238
238
/// assert_eq!("💖", sparkle_heart);
239
239
/// ```
240
240
#[ unstable( feature = "inherent_str_constructors" , issue = "131114" ) ]
241
+ #[ rustc_diagnostic_item = "str_inherent_from_utf8" ]
241
242
pub const fn from_utf8 ( v : & [ u8 ] ) -> Result < & str , Utf8Error > {
242
243
converts:: from_utf8 ( v)
243
244
}
@@ -249,7 +250,7 @@ impl str {
249
250
/// Basic usage:
250
251
///
251
252
/// ```
252
- /// use std::str;
253
+ /// #![feature(inherent_str_constructors)]
253
254
///
254
255
/// // "Hello, Rust!" as a mutable vector
255
256
/// let mut hellorust = vec![72, 101, 108, 108, 111, 44, 32, 82, 117, 115, 116, 33];
@@ -263,7 +264,7 @@ impl str {
263
264
/// Incorrect bytes:
264
265
///
265
266
/// ```
266
- /// use std::str;
267
+ /// #![feature(inherent_str_constructors)]
267
268
///
268
269
/// // Some invalid bytes in a mutable vector
269
270
/// let mut invalid = vec![128, 223];
@@ -274,6 +275,7 @@ impl str {
274
275
/// errors that can be returned.
275
276
#[ unstable( feature = "inherent_str_constructors" , issue = "131114" ) ]
276
277
#[ rustc_const_unstable( feature = "const_str_from_utf8" , issue = "91006" ) ]
278
+ #[ rustc_diagnostic_item = "str_inherent_from_utf8_mut" ]
277
279
pub const fn from_utf8_mut ( v : & mut [ u8 ] ) -> Result < & mut str , Utf8Error > {
278
280
converts:: from_utf8_mut ( v)
279
281
}
@@ -292,7 +294,7 @@ impl str {
292
294
/// Basic usage:
293
295
///
294
296
/// ```
295
- /// use std::str;
297
+ /// #![feature(inherent_str_constructors)]
296
298
///
297
299
/// // some bytes, in a vector
298
300
/// let sparkle_heart = vec![240, 159, 146, 150];
@@ -306,6 +308,7 @@ impl str {
306
308
#[ inline]
307
309
#[ must_use]
308
310
#[ unstable( feature = "inherent_str_constructors" , issue = "131114" ) ]
311
+ #[ rustc_diagnostic_item = "str_inherent_from_utf8_unchecked" ]
309
312
pub const unsafe fn from_utf8_unchecked ( v : & [ u8 ] ) -> & str {
310
313
// SAFETY: converts::from_utf8_unchecked has the same safety requirements as this function.
311
314
unsafe { converts:: from_utf8_unchecked ( v) }
@@ -321,7 +324,7 @@ impl str {
321
324
/// Basic usage:
322
325
///
323
326
/// ```
324
- /// use std::str;
327
+ /// #![feature(inherent_str_constructors)]
325
328
///
326
329
/// let mut heart = vec![240, 159, 146, 150];
327
330
/// let heart = unsafe { str::from_utf8_unchecked_mut(&mut heart) };
@@ -331,6 +334,7 @@ impl str {
331
334
#[ inline]
332
335
#[ must_use]
333
336
#[ unstable( feature = "inherent_str_constructors" , issue = "131114" ) ]
337
+ #[ rustc_diagnostic_item = "str_inherent_from_utf8_unchecked_mut" ]
334
338
pub const unsafe fn from_utf8_unchecked_mut ( v : & mut [ u8 ] ) -> & mut str {
335
339
// SAFETY: converts::from_utf8_unchecked_mut has the same safety requirements as this function.
336
340
unsafe { converts:: from_utf8_unchecked_mut ( v) }
0 commit comments