lines
fn lines(string s) -> Result<Vec<string>, string> Import
Source: use text::{lines}; src/text.hy Splits s into lines at each LF, dropping one CR before it (so CRLF works too).
Parameters#
| Name | Type |
|---|---|
s | string |
Returns#
Result<Vec<string>, string>
Examples#
use text::{lines};
use tests::assert;
let ls = lines("one\r\ntwo\nthree") ?? Vec::new();
assert!(ls.len() == 3);
assert!(ls[0] == "one");
See also#
byte_len: Returns the length ofsin bytes; the same ass.len().slice: Returns the part ofsfrom byte offsetstartup to (not including)end.trim_start: Returnsswithout leading ASCII whitespace (space, tab, CR, LF).trim_end: Returnsswithout trailing ASCII whitespace (space, tab, CR, LF).trim: Returnsswithout leading and trailing ASCII whitespace (space, tab, CR, LF).rfind: Returns the byte offset of the lastneedleinhay, or-1.split_at: Splitssat byte offsetatinto the part before and the part fromaton.join: Returns thepartsconcatenated withsepbetween each pair.