Secret(s.into())
}
#[throws(AE)]
- fn default() -> Self { Secret(default()) }
+ fn default_for_ordinary() -> Self { Secret(default()) }
}
impl Debug for Secret {
#[throws(fmt::Error)]
trait Parseable: Sized {
fn parse(s: Option<&str>) -> Result<Self, AE>;
- fn default() -> Result<Self, AE> {
+
+ /// Used for lookups with [`ResolveContest::ordinary`] etc.
+ ///
+ /// Fails, if this setting ought to have been specified.
+ /// The caller will add a key name to the error.
+ fn default_for_ordinary() -> Result<Self, AE> {
Err(anyhow!("setting must be specified"))
}
- #[throws(AE)]
- fn default_for_key(key: &str) -> Self {
- Self::default().with_context(|| key.to_string())?
- }
}
impl Parseable for Duration {
impl Parseable for $t {
#[throws(AE)]
fn parse(s: Option<&str>) -> $t { s.value()?.parse()? }
- $( #[throws(AE)] fn default() -> Self { $def } )?
+ $( #[throws(AE)] fn default_for_ordinary() -> Self { $def } )?
}
} }
parseable_from_str!{u16, default() }
.collect::<Result<Vec<_>,_>>()?
}
#[throws(AE)]
- fn default() -> Self { default() }
+ fn default_for_ordinary() -> Self { default() }
}
{
match self.first_of(key, skl)? {
Some(y) => y,
- None => Parseable::default_for_key(key)?,
+ None => Parseable::default_for_ordinary()
+ .with_context(|| key.to_string())?,
}
}