Function in text coil-stdlib

lines

fn lines(string s) -> Result<Vec<string>, string>
Import
use text::{lines};
Source: src/text.hy

Splits s into lines at each LF, dropping one CR before it (so CRLF works too).

Parameters#

NameType
sstring

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 of s in bytes; the same as s.len().
  • slice: Returns the part of s from byte offset start up to (not including) end.
  • trim_start: Returns s without leading ASCII whitespace (space, tab, CR, LF).
  • trim_end: Returns s without trailing ASCII whitespace (space, tab, CR, LF).
  • trim: Returns s without leading and trailing ASCII whitespace (space, tab, CR, LF).
  • rfind: Returns the byte offset of the last needle in hay, or -1.
  • split_at: Splits s at byte offset at into the part before and the part from at on.
  • join: Returns the parts concatenated with sep between each pair.
↑ ↓ navigate ↵ open