-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathdiluting.rs
36 lines (32 loc) · 1.02 KB
/
diluting.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
use rustybeer::calculators::diluting::calculate_new_gravity;
use rustybeer::conversions::{RelativeDensity, RelativeDensityParser, ToMap, VolumeParser};
use rustybeer::measurements::Volume;
use structopt::StructOpt;
#[derive(Debug, StructOpt)]
#[structopt(
name = "diluting",
author = "Joseph Russell ([email protected])"
)]
/// Calculates the SG after dilution
pub struct DilutingOptions {
#[structopt(short, long, parse(try_from_str = RelativeDensityParser::parse))]
/// Current specific gravity
sg: RelativeDensity,
#[structopt(short, long, parse(try_from_str = VolumeParser::parse))]
/// Current Volume
cv: Volume,
#[structopt(short, long, parse(try_from_str = VolumeParser::parse))]
/// Target Volume
tv: Volume,
}
pub fn calculate_and_print(diluting_options: DilutingOptions) {
println!(
"New SG: {:#?}",
calculate_new_gravity(
&diluting_options.sg,
&diluting_options.cv,
&diluting_options.tv
)
.to_map()
);
}