File tree 1 file changed +15
-5
lines changed
1 file changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -328,11 +328,16 @@ impl str {
328
328
/// # Examples
329
329
///
330
330
/// ```
331
- /// let v = "🗻∈🌏";
332
- /// assert_eq!(Some("🗻"), v.get(0..4));
333
- /// assert!(v.get(1..).is_none());
334
- /// assert!(v.get(..8).is_none());
335
- /// assert!(v.get(..42).is_none());
331
+ /// let mut v = String::from("🗻∈🌏");
332
+ ///
333
+ /// assert_eq!(Some("🗻"), v.get(0..4);
334
+ ///
335
+ /// // indices not on UTF-8 sequence boundaries
336
+ /// assert!(v.get_mut(1..).is_none());
337
+ /// assert!(v.get_mut(..8).is_none());
338
+ ///
339
+ /// // out of bounds
340
+ /// assert!(v.get_mut(..42).is_none());
336
341
/// ```
337
342
#[ stable( feature = "str_checked_slicing" , since = "1.20.0" ) ]
338
343
#[ inline]
@@ -351,9 +356,14 @@ impl str {
351
356
///
352
357
/// ```
353
358
/// let mut v = String::from("🗻∈🌏");
359
+ ///
354
360
/// assert_eq!(Some("🗻"), v.get_mut(0..4).map(|v| &*v));
361
+ ///
362
+ /// // indices not on UTF-8 sequence boundaries
355
363
/// assert!(v.get_mut(1..).is_none());
356
364
/// assert!(v.get_mut(..8).is_none());
365
+ ///
366
+ /// // out of bounds
357
367
/// assert!(v.get_mut(..42).is_none());
358
368
/// ```
359
369
#[ stable( feature = "str_checked_slicing" , since = "1.20.0" ) ]
You can’t perform that action at this time.
0 commit comments