INNER CODE UNIT · Rust
optional_string
logannye/rosalind · crates/receipt-wasm/src/lib.rs:311
fn optional_string(value: Option<&str>) -> String {
value
.map(|value| format!("\"{}\"", json_escape(value)))
.unwrap_or_else(|| "null".to_string())
}
fn tri_bool(value: Option<bool>) -> &'static str {
match value {
Some(true) => "true",
Some(false) => "false",
None => "null",
}
}
fn field_changes_json(changes: &[rosalind_receipt::FieldChange]) -> String {
let body = changes
.iter()
.map(|change| {