@@ -1311,13 +1311,19 @@ mod traits {
1311
1311
}
1312
1312
}
1313
1313
1314
+ /// Implements substring slicing with syntax `&self[begin .. end]`.
1315
+ ///
1314
1316
/// Returns a slice of the given string from the byte range
1315
1317
/// [`begin`..`end`).
1316
1318
///
1317
1319
/// This operation is `O(1)`.
1318
1320
///
1319
- /// Panics when `begin` and `end` do not point to valid characters
1320
- /// or point beyond the last character of the string.
1321
+ /// # Panics
1322
+ ///
1323
+ /// Panics if `begin` or `end` does not point to the starting
1324
+ /// byte offset of a character (as defined by `is_char_boundary`).
1325
+ /// Requires that `begin <= end` and `end <= len` where `len` is the
1326
+ /// length of the string.
1321
1327
///
1322
1328
/// # Examples
1323
1329
///
@@ -1353,8 +1359,20 @@ mod traits {
1353
1359
}
1354
1360
}
1355
1361
1362
+ /// Implements mutable substring slicing with syntax
1363
+ /// `&mut self[begin .. end]`.
1364
+ ///
1356
1365
/// Returns a mutable slice of the given string from the byte range
1357
1366
/// [`begin`..`end`).
1367
+ ///
1368
+ /// This operation is `O(1)`.
1369
+ ///
1370
+ /// # Panics
1371
+ ///
1372
+ /// Panics if `begin` or `end` does not point to the starting
1373
+ /// byte offset of a character (as defined by `is_char_boundary`).
1374
+ /// Requires that `begin <= end` and `end <= len` where `len` is the
1375
+ /// length of the string.
1358
1376
#[ stable( feature = "derefmut_for_string" , since = "1.2.0" ) ]
1359
1377
impl ops:: IndexMut < ops:: Range < usize > > for str {
1360
1378
#[ inline]
@@ -1370,13 +1388,12 @@ mod traits {
1370
1388
}
1371
1389
}
1372
1390
1373
- /// Returns a slice of the string from the beginning to byte
1374
- /// `end`.
1391
+ /// Implements substring slicing with syntax `&self[.. end]`.
1375
1392
///
1376
- /// Equivalent to `self[0 .. end]`.
1393
+ /// Returns a slice of the string from the beginning to byte offset
1394
+ /// `end`.
1377
1395
///
1378
- /// Panics when `end` does not point to a valid character, or is
1379
- /// out of bounds.
1396
+ /// Equivalent to `&self[0 .. end]`.
1380
1397
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1381
1398
impl ops:: Index < ops:: RangeTo < usize > > for str {
1382
1399
type Output = str ;
@@ -1392,8 +1409,12 @@ mod traits {
1392
1409
}
1393
1410
}
1394
1411
1395
- /// Returns a mutable slice of the string from the beginning to byte
1412
+ /// Implements mutable substring slicing with syntax `&mut self[.. end]`.
1413
+ ///
1414
+ /// Returns a mutable slice of the string from the beginning to byte offset
1396
1415
/// `end`.
1416
+ ///
1417
+ /// Equivalent to `&mut self[0 .. end]`.
1397
1418
#[ stable( feature = "derefmut_for_string" , since = "1.2.0" ) ]
1398
1419
impl ops:: IndexMut < ops:: RangeTo < usize > > for str {
1399
1420
#[ inline]
@@ -1407,12 +1428,12 @@ mod traits {
1407
1428
}
1408
1429
}
1409
1430
1410
- /// Returns a slice of the string from ` begin` to its end .
1431
+ /// Implements substring slicing with syntax `&self[ begin ..]` .
1411
1432
///
1412
- /// Equivalent to `self[begin .. self.len()]`.
1433
+ /// Returns a slice of the string from byte offset `begin`
1434
+ /// to the end of the string.
1413
1435
///
1414
- /// Panics when `begin` does not point to a valid character, or is
1415
- /// out of bounds.
1436
+ /// Equivalent to `&self[begin .. len]`.
1416
1437
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1417
1438
impl ops:: Index < ops:: RangeFrom < usize > > for str {
1418
1439
type Output = str ;
@@ -1428,7 +1449,12 @@ mod traits {
1428
1449
}
1429
1450
}
1430
1451
1431
- /// Returns a slice of the string from `begin` to its end.
1452
+ /// Implements mutable substring slicing with syntax `&mut self[begin ..]`.
1453
+ ///
1454
+ /// Returns a mutable slice of the string from byte offset `begin`
1455
+ /// to the end of the string.
1456
+ ///
1457
+ /// Equivalent to `&mut self[begin .. len]`.
1432
1458
#[ stable( feature = "derefmut_for_string" , since = "1.2.0" ) ]
1433
1459
impl ops:: IndexMut < ops:: RangeFrom < usize > > for str {
1434
1460
#[ inline]
@@ -1443,6 +1469,12 @@ mod traits {
1443
1469
}
1444
1470
}
1445
1471
1472
+ /// Implements substring slicing with syntax `&self[..]`.
1473
+ ///
1474
+ /// Returns a slice of the whole string. This operation can
1475
+ /// never panic.
1476
+ ///
1477
+ /// Equivalent to `&self[0 .. len]`.
1446
1478
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1447
1479
impl ops:: Index < ops:: RangeFull > for str {
1448
1480
type Output = str ;
@@ -1453,6 +1485,12 @@ mod traits {
1453
1485
}
1454
1486
}
1455
1487
1488
+ /// Implements mutable substring slicing with syntax `&mut self[..]`.
1489
+ ///
1490
+ /// Returns a mutable slice of the whole string. This operation can
1491
+ /// never panic.
1492
+ ///
1493
+ /// Equivalent to `&mut self[0 .. len]`.
1456
1494
#[ stable( feature = "derefmut_for_string" , since = "1.2.0" ) ]
1457
1495
impl ops:: IndexMut < ops:: RangeFull > for str {
1458
1496
#[ inline]
0 commit comments