Skip to main content

string_field

Function string_field 

Source
pub fn string_field<'a>(
    map: &'a Map<String, Value>,
    key: &str,
) -> Option<&'a str>
Expand description

What: Read a field as text, or nothing when it is absent or not a string. Why: typeof value.key === 'string' is the incumbent’s check.

In TS you’d write (pseudocode):

typeof value[key] === 'string' ? value[key] : undefined