Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pub fn list(output: String) -> Option<Vec<String>> {
- let mut list = Vec::new();
- for line in output.lines() {
- let name = line.split_whitespace().next();
- if let Some(snap_name) = name {
- list.push(snap_name.to_string());
- }
- }
- Some(list.into_iter().filter(|x| x != "NAME").collect())
- }
- fn main() {
- let output = "NAME USED AVAIL REFER MOUNTPOINT
- rpool@gitlab 0 - 128K -
- rpool/ROOT/ubuntu@version1 6,20M - 643M -
- rpool/ROOT/ubuntu@gitlab1 211M - 898M -"
- .to_string();
- let s = list(output);
- assert_eq!(Some([
- "rpool@gitlab",
- "rpool/ROOT/ubuntu@version1",
- "rpool/ROOT/ubuntu@gitlab1"
- ].iter().map(|s| s.to_string()).collect()), s);
- println!("{:?}", s);
- }
Add Comment
Please, Sign In to add comment