mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 15:23:46 +00:00
Updated lines doc to include trailing carriage return note
This commit is contained in:
parent
b12ff66f2c
commit
116aacc2a9
@ -952,6 +952,10 @@ impl str {
|
||||
///
|
||||
/// Line terminators are not included in the lines returned by the iterator.
|
||||
///
|
||||
/// Note that any carriage return (`\r`) not immediately followed by a
|
||||
/// line feed (`\n`) does not split a line. These carriage returns are
|
||||
/// thereby included in the produced lines.
|
||||
///
|
||||
/// The final line ending is optional. A string that ends with a final line
|
||||
/// ending will return the same lines as an otherwise identical string
|
||||
/// without a final line ending.
|
||||
@ -961,18 +965,19 @@ impl str {
|
||||
/// Basic usage:
|
||||
///
|
||||
/// ```
|
||||
/// let text = "foo\r\nbar\n\nbaz\n";
|
||||
/// let text = "foo\r\nbar\n\nbaz\r";
|
||||
/// let mut lines = text.lines();
|
||||
///
|
||||
/// assert_eq!(Some("foo"), lines.next());
|
||||
/// assert_eq!(Some("bar"), lines.next());
|
||||
/// assert_eq!(Some(""), lines.next());
|
||||
/// assert_eq!(Some("baz"), lines.next());
|
||||
/// // Trailing carriage return is included in the last line
|
||||
/// assert_eq!(Some("baz\r"), lines.next());
|
||||
///
|
||||
/// assert_eq!(None, lines.next());
|
||||
/// ```
|
||||
///
|
||||
/// The final line ending isn't required:
|
||||
/// The final line does not require any ending:
|
||||
///
|
||||
/// ```
|
||||
/// let text = "foo\nbar\n\r\nbaz";
|
||||
|
Loading…
Reference in New Issue
Block a user