#localization #sports #sport #training #running

librunner

Rust library to assist runners on planning their workouts, races, and improve their health

6 releases (3 breaking)

0.4.0 May 23, 2023
0.3.0 May 16, 2023
0.2.2 May 5, 2023
0.1.0 May 3, 2023

#93 in Internationalization (i18n)

Download history 27/week @ 2023-04-28 69/week @ 2023-05-05 30/week @ 2023-05-12 29/week @ 2023-05-19 10/week @ 2023-05-26

147 downloads per month

Apache-2.0

18KB
264 lines

Lib Runner

Rust library to assist runners on planning their workouts, races, and improve their health.

Usage

Run the following Cargo command in your project folder:

$ cargo add librunner

Call it in the source code:

use std::time::Duration;
use librunner::running::{Race, MetricRace, ImperialRace};
use librunner::utils::convert;

fn main() {
    let duration = convert::to_duration(4, 0, 0); // 04:00:00
    let m_race: MetricRace = Race::new(42195, duration);
    let m_average_pace = m_race.average_pace();

    println!("The pace to run {}km in {}h is approximately {}.{}/km at {:.2}km/h", 
             (m_race.distance as f32 / 1000.0), 
             (duration.as_secs() / 60 / 60), 
             (m_average_pace.as_secs() / 60),
             (m_average_pace.as_secs() % 60),
             (m_race.speed() * 3.6));

    let i_race: ImperialRace = Race::new(46112, duration);
    let i_average_pace = i_race.average_pace();

    println!("The pace to run {} miles in {}h is approximately {}.{}/mile at {:.2}mph", 
             (i_race.distance as f32 / 1760.0), 
             (duration.as_secs() / 60 / 60),
             (i_average_pace.as_secs() / 60),
             (i_average_pace.as_secs() % 60),
             (i_race.speed() * 3.6));
}

No runtime deps