mind-body: need() as a fn so the borrowed value outlives the closure
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
4b3e850fef
commit
76367e888a
1 changed files with 4 additions and 1 deletions
|
|
@ -70,7 +70,6 @@ fn parse_dial(flags: &[&str], now: DateTime<Utc>, set_by: &str) -> Result<BurnRa
|
|||
bail!("{flag} given twice");
|
||||
}
|
||||
}
|
||||
let need = |value: Option<&str>, name: &str| value.ok_or_else(|| anyhow!("{name} is required"));
|
||||
Ok(BurnRate {
|
||||
heat: Decimal::from_str(need(heat, "--heat")?).context("--heat is not a decimal")?,
|
||||
base_cooldown_s: need(cooldown, "--base-cooldown-s")?
|
||||
|
|
@ -82,6 +81,10 @@ fn parse_dial(flags: &[&str], now: DateTime<Utc>, set_by: &str) -> Result<BurnRa
|
|||
})
|
||||
}
|
||||
|
||||
fn need<'a>(value: Option<&'a str>, name: &str) -> Result<&'a str> {
|
||||
value.ok_or_else(|| anyhow!("{name} is required"))
|
||||
}
|
||||
|
||||
fn show(path: &Path, instance: &Slug, out: &mut impl Write) -> Result<()> {
|
||||
let source = FileSource::new(path);
|
||||
writeln!(out, "instance: {}", instance.0)?;
|
||||
|
|
|
|||
Loading…
Reference in a new issue