@@ -1489,10 +1489,11 @@ impl String {
1489
1489
Some ( ch)
1490
1490
}
1491
1491
1492
- /// Removes a [`char`] from this `String` at a byte position and returns it.
1492
+ /// Removes a [`char`] from this `String` at byte position `idx` and returns it.
1493
1493
///
1494
- /// This is an *O*(*n*) operation, as it requires copying every element in the
1495
- /// buffer.
1494
+ /// Copies all bytes after the removed char to new positions.
1495
+ ///
1496
+ /// NB Calling this in a loop can result in quadratic behavior.
1496
1497
///
1497
1498
/// # Panics
1498
1499
///
@@ -1678,10 +1679,14 @@ impl String {
1678
1679
drop ( guard) ;
1679
1680
}
1680
1681
1681
- /// Inserts a character into this `String` at a byte position.
1682
+ /// Inserts a character into this `String` at byte position `idx`.
1683
+ ///
1684
+ /// Reallocates if `self.capacity()` is insufficient,
1685
+ /// which may involve copying all `self.capacity()` bytes.
1686
+ /// Makes space for the insertion,
1687
+ /// by copying all bytes of `&self[idx..]` to new positions.
1682
1688
///
1683
- /// This is an *O*(*n*) operation as it requires copying every element in the
1684
- /// buffer.
1689
+ /// NB Calling this in a loop can result in quadratic behavior.
1685
1690
///
1686
1691
/// # Panics
1687
1692
///
@@ -1733,10 +1738,14 @@ impl String {
1733
1738
}
1734
1739
}
1735
1740
1736
- /// Inserts a string slice into this `String` at a byte position.
1741
+ /// Inserts a string slice into this `String` at byte position `idx`.
1742
+ ///
1743
+ /// Reallocates if `self.capacity()` is insufficient,
1744
+ /// which may involve copying all `self.capacity()` bytes.
1745
+ /// Makes space for the insertion,
1746
+ /// by copying all bytes of `&self[idx..]` to new positions.
1737
1747
///
1738
- /// This is an *O*(*n*) operation as it requires copying every element in the
1739
- /// buffer.
1748
+ /// NB Calling this in a loop can result in quadratic behavior.
1740
1749
///
1741
1750
/// # Panics
1742
1751
///
0 commit comments