@@ -1486,10 +1486,11 @@ impl String {
1486
1486
Some ( ch)
1487
1487
}
1488
1488
1489
- /// Removes a [`char`] from this `String` at a byte position and returns it.
1489
+ /// Removes a [`char`] from this `String` at byte position `idx` and returns it.
1490
1490
///
1491
- /// This is an *O*(*n*) operation, as it requires copying every element in the
1492
- /// buffer.
1491
+ /// Copies all bytes after the removed char to new positions.
1492
+ ///
1493
+ /// NB Calling this in a loop can result in quadratic behavior.
1493
1494
///
1494
1495
/// # Panics
1495
1496
///
@@ -1675,10 +1676,14 @@ impl String {
1675
1676
drop ( guard) ;
1676
1677
}
1677
1678
1678
- /// Inserts a character into this `String` at a byte position.
1679
+ /// Inserts a character into this `String` at byte position `idx`.
1680
+ ///
1681
+ /// Reallocates if `self.capacity()` is insufficient,
1682
+ /// which may involve copying all `self.capacity()` bytes.
1683
+ /// Makes space for the insertion,
1684
+ /// by copying all bytes of `&self[idx..]` to new positions.
1679
1685
///
1680
- /// This is an *O*(*n*) operation as it requires copying every element in the
1681
- /// buffer.
1686
+ /// NB Calling this in a loop can result in quadratic behavior.
1682
1687
///
1683
1688
/// # Panics
1684
1689
///
@@ -1723,10 +1728,14 @@ impl String {
1723
1728
}
1724
1729
}
1725
1730
1726
- /// Inserts a string slice into this `String` at a byte position.
1731
+ /// Inserts a string slice into this `String` at byte position `idx`.
1732
+ ///
1733
+ /// Reallocates if `self.capacity()` is insufficient,
1734
+ /// which may involve copying all `self.capacity()` bytes.
1735
+ /// Makes space for the insertion,
1736
+ /// by copying all bytes of `&self[idx..]` to new positions.
1727
1737
///
1728
- /// This is an *O*(*n*) operation as it requires copying every element in the
1729
- /// buffer.
1738
+ /// NB Calling this in a loop can result in quadratic behavior.
1730
1739
///
1731
1740
/// # Panics
1732
1741
///
0 commit comments