MCPcopy Create free account
hub / github.com/Work-Fisher/code-claw / optional_string

Function optional_string

claw-code/rust/crates/runtime/src/config.rs:670–682  ·  view source on GitHub ↗
(
    object: &'a BTreeMap<String, JsonValue>,
    key: &str,
    context: &str,
)

Source from the content-addressed store, hash-verified

668}
669
670fn optional_string<'a>(
671 object: &'a BTreeMap<String, JsonValue>,
672 key: &str,
673 context: &str,
674) -> Result<Option<&'a str>, ConfigError> {
675 match object.get(key) {
676 Some(value) => value
677 .as_str()
678 .map(Some)
679 .ok_or_else(|| ConfigError::Parse(format!("{context}: field {key} must be a string"))),
680 None => Ok(None),
681 }
682}
683
684fn optional_bool(
685 object: &BTreeMap<String, JsonValue>,

Calls 2

getMethod · 0.80
as_strMethod · 0.45

Tested by

no test coverage detected