1pub fn split_first<'a>(line: &'a str) -> Option<(&'a str, &'a str)> {
2 match line.find('\t') {
3 Some(i) => Some((&line[0..i], &line[(i + 1)..])),
4 None => None,
5 }
6}
7
8#[test]
9fn split_empty() {
10 assert_eq!(split_first(""), None)
11}
12
13#[test]
14fn split_tab() {
15 assert_eq!(split_first("foo\tbar"), Some(("foo", "bar")))
16}
17
18#[test]
19fn split_end() {
20 assert_eq!(split_first("foo\t"), Some(("foo", "")))
21}
22
23#[test]
24fn split_2() {
25 assert_eq!(split_first("foo\tbar\tblatz"), Some(("foo", "bar\tblatz")))
26}