MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / parse_optional_number

Function parse_optional_number

src/automation_cli.rs:830–850  ·  view source on GitHub ↗
(
    value: Option<String>,
    field: &str,
    parse: impl FnOnce(&str) -> std::result::Result<T, E>,
)

Source from the content-addressed store, hash-verified

828}
829
830fn parse_optional_number<T, E>(
831 value: Option<String>,
832 field: &str,
833 parse: impl FnOnce(&str) -> std::result::Result<T, E>,
834) -> tracedecay::errors::Result<Option<Option<T>>>
835where
836 E: std::fmt::Display,
837{
838 let Some(value) = value else {
839 return Ok(None);
840 };
841 if string_clears_optional(&value) {
842 return Ok(Some(None));
843 }
844 parse(&value)
845 .map(Some)
846 .map(Some)
847 .map_err(|err| tracedecay::errors::TraceDecayError::Config {
848 message: format!("invalid automation config value for {field}: {err}"),
849 })
850}
851
852fn print_automation_config(
853 global: &tracedecay::automation::config::AutomationConfig,

Callers 3

parse_optional_u64Function · 0.85
parse_optional_u32Function · 0.85
parse_optional_f32Function · 0.85

Calls 2

string_clears_optionalFunction · 0.85
parseFunction · 0.70

Tested by

no test coverage detected