style: code style
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::{ self, Lines, BufRead, BufReader };
|
use std::io::{ self, Lines, BufRead, BufReader };
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use regex::{RegexSet};
|
use regex::RegexSet;
|
||||||
use crate::token::*;
|
use crate::token::*;
|
||||||
|
|
||||||
// The output is wrapped in a Result to allow matching on errors
|
// The output is wrapped in a Result to allow matching on errors
|
||||||
|
|||||||
13
src/token.rs
13
src/token.rs
@@ -1,5 +1,5 @@
|
|||||||
use chrono::NaiveDate;
|
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
use chrono::NaiveDate;
|
||||||
use colored::Colorize;
|
use colored::Colorize;
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
|
|
||||||
@@ -45,21 +45,12 @@ impl Token {
|
|||||||
let year = capture.get(1).unwrap().as_str().parse::<i32>().unwrap();
|
let year = capture.get(1).unwrap().as_str().parse::<i32>().unwrap();
|
||||||
let month = capture.get(2).unwrap().as_str().parse::<u32>().unwrap();
|
let month = capture.get(2).unwrap().as_str().parse::<u32>().unwrap();
|
||||||
let day = capture.get(3).unwrap().as_str().parse::<u32>().unwrap();
|
let day = capture.get(3).unwrap().as_str().parse::<u32>().unwrap();
|
||||||
|
|
||||||
t.date = NaiveDate::from_ymd_opt(year, month, day);
|
t.date = NaiveDate::from_ymd_opt(year, month, day);
|
||||||
}
|
}
|
||||||
// let date: Vec<&str> = field.split('/').collect();
|
|
||||||
// let year = date[0].parse::<i32>().unwrap();
|
|
||||||
// let month = date[1].parse::<u32>().unwrap();
|
|
||||||
// let day = date[2].parse::<u32>().unwrap();
|
|
||||||
// t.date = NaiveDate::from_ymd_opt(year, month, day);
|
|
||||||
} else if member_regex.is_match(field) {
|
} else if member_regex.is_match(field) {
|
||||||
t.member = Some(field.chars().skip(1).collect::<String>());
|
t.member = Some(field.chars().skip(1).collect::<String>());
|
||||||
} else {
|
} else {
|
||||||
t.comment = match t.comment {
|
t.comment = t.comment.map_or_else(|| Some(field.to_string()), |comment| Some(format!("{} {}", comment, field)));
|
||||||
None => Some(field.to_string()),
|
|
||||||
Some(comment) => Some(format!("{} {}", comment, field)),
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user