Skip to content

Commit d64000b

Browse files
committed
Auto merge of #114236 - fee1-dead-contrib:rollup-m92j7q1, r=fee1-dead
Rollup of 3 pull requests Successful merges: - #112151 (Clarify behavior of inclusive bounds in BTreeMap::{lower,upper}_bound) - #113512 (Updated lines doc to include trailing carriage return note) - #114203 (Effects: don't print `host` param in diagnostics) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 066e02d + e8ba34d commit d64000b

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

alloc/src/collections/btree/map.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2543,6 +2543,8 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
25432543
/// a.insert(2, "b");
25442544
/// a.insert(3, "c");
25452545
/// a.insert(4, "c");
2546+
/// let cursor = a.lower_bound(Bound::Included(&2));
2547+
/// assert_eq!(cursor.key(), Some(&2));
25462548
/// let cursor = a.lower_bound(Bound::Excluded(&2));
25472549
/// assert_eq!(cursor.key(), Some(&3));
25482550
/// ```
@@ -2582,6 +2584,8 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
25822584
/// a.insert(2, "b");
25832585
/// a.insert(3, "c");
25842586
/// a.insert(4, "c");
2587+
/// let cursor = a.lower_bound_mut(Bound::Included(&2));
2588+
/// assert_eq!(cursor.key(), Some(&2));
25852589
/// let cursor = a.lower_bound_mut(Bound::Excluded(&2));
25862590
/// assert_eq!(cursor.key(), Some(&3));
25872591
/// ```
@@ -2634,6 +2638,8 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
26342638
/// a.insert(2, "b");
26352639
/// a.insert(3, "c");
26362640
/// a.insert(4, "c");
2641+
/// let cursor = a.upper_bound(Bound::Included(&3));
2642+
/// assert_eq!(cursor.key(), Some(&3));
26372643
/// let cursor = a.upper_bound(Bound::Excluded(&3));
26382644
/// assert_eq!(cursor.key(), Some(&2));
26392645
/// ```
@@ -2673,6 +2679,8 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
26732679
/// a.insert(2, "b");
26742680
/// a.insert(3, "c");
26752681
/// a.insert(4, "c");
2682+
/// let cursor = a.upper_bound_mut(Bound::Included(&3));
2683+
/// assert_eq!(cursor.key(), Some(&3));
26762684
/// let cursor = a.upper_bound_mut(Bound::Excluded(&3));
26772685
/// assert_eq!(cursor.key(), Some(&2));
26782686
/// ```

core/src/str/mod.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -952,6 +952,10 @@ impl str {
952952
///
953953
/// Line terminators are not included in the lines returned by the iterator.
954954
///
955+
/// Note that any carriage return (`\r`) not immediately followed by a
956+
/// line feed (`\n`) does not split a line. These carriage returns are
957+
/// thereby included in the produced lines.
958+
///
955959
/// The final line ending is optional. A string that ends with a final line
956960
/// ending will return the same lines as an otherwise identical string
957961
/// without a final line ending.
@@ -961,18 +965,19 @@ impl str {
961965
/// Basic usage:
962966
///
963967
/// ```
964-
/// let text = "foo\r\nbar\n\nbaz\n";
968+
/// let text = "foo\r\nbar\n\nbaz\r";
965969
/// let mut lines = text.lines();
966970
///
967971
/// assert_eq!(Some("foo"), lines.next());
968972
/// assert_eq!(Some("bar"), lines.next());
969973
/// assert_eq!(Some(""), lines.next());
970-
/// assert_eq!(Some("baz"), lines.next());
974+
/// // Trailing carriage return is included in the last line
975+
/// assert_eq!(Some("baz\r"), lines.next());
971976
///
972977
/// assert_eq!(None, lines.next());
973978
/// ```
974979
///
975-
/// The final line ending isn't required:
980+
/// The final line does not require any ending:
976981
///
977982
/// ```
978983
/// let text = "foo\nbar\n\r\nbaz";

0 commit comments

Comments
 (0)