fn parse_activity(line: &str) -> Result<Activity> {
    let mut parts = line.split(';');

    //let mut timestamp: DateTime<Local> = Local::now();
    let mut category: String = String::new();

    let timestamp = match parts.next() {
        Some(ts) => str2ts(ts)?,
        None => bail!("No activity timestamp found"),
    };

    let reps = match parts.next() {
        Some(rep_str) => rep_str.trim().parse().with_context(|| {
            format!(
                "Repetitions <{}> can not be parsed as whole number",
                rep_str
            )
        })?,
        None => bail!("No repetitions found"),
    };

    if let Some(cat) = parts.next() {
        category = cat.trim().to_string();
    }

    Ok(Activity {
        timestamp,
        reps,
        category,
    })
}
/// parse a single line from an activity file into an Activity struct
parse a single line from an activity file into an Activity struct
parse a single line from an activity file into an Activity struct
fn parse_activity(line: &str) -> Result<Activity> {
    let mut parts = line.split(';');
    //let mut timestamp: DateTime<Local> = Local::now();
    let mut category: String = String::new();
    let timestamp = match parts.next() {
        Some(ts) => str2ts(ts)?,
        None => bail!("No activity timestamp found"),
    };
    let reps = match parts.next() {
        Some(rep_str) => rep_str.trim().parse().with_context(|| {
            format!(
                "Repetitions <{}> can not be parsed as whole number",
                rep_str
            )
        })?,
        None => bail!("No repetitions found"),
    };
    if let Some(cat) = parts.next() {
        category = cat.trim().to_string();
    }
    Ok(Activity {
        timestamp,
        reps,
        category,
    })
}
fn parse_activity ( line : & str ) -> Result < Activity > { let mut parts = line . split ( ';' ) ; //let mut timestamp: DateTime<Local> = Local::now(); let mut category : String = String :: new ( ) ; let timestamp = match parts . next ( ) { Some ( ts ) => str2ts ( ts ) ? , None => bail ! ( " " ) , } ; let reps = match parts . next ( ) { Some ( rep_str ) => rep_str . trim ( ) . parse ( ) . with_context ( | | { format ! ( " " rep_str ) } ) ? , None => bail ! ( " " ) , } ; if let Some ( cat ) = parts . next ( ) { category = cat . trim ( ) . to_string ( ) ; } Ok ( Activity { timestamp , reps , category , } ) }
parse a single line from an activity file into an Activity struct
parse a single line from an activity file into an Activity struct
line
&str