@@ -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
+ /// Note that calling this in a loop can result in quadratic behavior.
1496
1497
///
1497
1498
/// # Panics
1498
1499
///
@@ -1678,10 +1679,13 @@ 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 by copying all bytes of `&self[idx..]` to new positions.
1682
1687
///
1683
- /// This is an *O*(*n*) operation as it requires copying every element in the
1684
- /// buffer.
1688
+ /// Note that calling this in a loop can result in quadratic behavior.
1685
1689
///
1686
1690
/// # Panics
1687
1691
///
@@ -1733,10 +1737,13 @@ impl String {
1733
1737
}
1734
1738
}
1735
1739
1736
- /// Inserts a string slice into this `String` at a byte position.
1740
+ /// Inserts a string slice into this `String` at byte position `idx`.
1741
+ ///
1742
+ /// Reallocates if `self.capacity()` is insufficient,
1743
+ /// which may involve copying all `self.capacity()` bytes.
1744
+ /// Makes space for the insertion by copying all bytes of `&self[idx..]` to new positions.
1737
1745
///
1738
- /// This is an *O*(*n*) operation as it requires copying every element in the
1739
- /// buffer.
1746
+ /// Note that calling this in a loop can result in quadratic behavior.
1740
1747
///
1741
1748
/// # Panics
1742
1749
///
0 commit comments