In my opinion, there is a much simpler solution to this problem, namely the use of the .splitn() method. This method breaks a string according to a given pattern no more than n times. For instance:
let s = "ab:bc:cd:de:ef".to_string(); println!("{:?}", s.splitn(3, ':').collect::<Vec<_>>()); // ^ prints ["ab", "bc", "cd:de:ef"]
In your case, you need to break the string into 4 parts, separated by the ':' character, and take the fourth (with an index of 0):
// assuming the line is correctly formatted let date = l.splitn(4, ':').nth(3).unwrap();
If you do not want to use a spread (the string may be formatted incorrectly):
if let Some(date) = l.splitn(4, ':').nth(3) {
source share