INNER CODE UNIT · Rust

diff_receipts

logannye/rosalind · crates/receipt-wasm/src/lib.rs:128

pub fn diff_receipts(a: &str, b: &str) -> String {
    let Ok(a) = RunManifest::from_canonical_json(a) else {
        return "{\"ok\":false,\"error\":\"first receipt is not parseable\"}".to_string();
    };
    let Ok(b) = RunManifest::from_canonical_json(b) else {
        return "{\"ok\":false,\"error\":\"second receipt is not parseable\"}".to_string();
    };
    let diff = diff_core(&a, &b);
    format!(
        "{{\"ok\":true,\"claims_identical\":{},\"verdict\":\"{}\",\"inputs\":{},\"outputs\":{},\"code_identity\":{},\"science_params\":{},\"measurements\":{}}}",
        diff.claims_identical,
        json_escape(&diff.verdict()),
        operand_changes_json(&diff.inputs),
        operand_changes_json(&diff.outputs),
        field_changes_json(&diff.code_identity),
        field_changes_json(&diff.science_params),
        field_changes_json(&diff.measurements),
    )

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…