Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

tsv.rs 507 B

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
  1. pub 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. #[test]
  8. fn split_empty() {
  9. assert_eq!(split_first(""), None)
  10. }
  11. #[test]
  12. fn split_tab() {
  13. assert_eq!(split_first("foo\tbar"), Some(("foo", "bar")))
  14. }
  15. #[test]
  16. fn split_end() {
  17. assert_eq!(split_first("foo\t"), Some(("foo", "")))
  18. }
  19. #[test]
  20. fn split_2() {
  21. assert_eq!(split_first("foo\tbar\tblatz"), Some(("foo", "bar\tblatz")))
  22. }
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...