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