INNER CODE UNIT · Rust
walk_receipt_chain
logannye/rosalind · crates/receipt-wasm/src/lib.rs:151
pub fn walk_receipt_chain(receipts_jsonl: &str) -> String {
let mut receipts = Vec::new();
for (line, text) in receipts_jsonl.lines().filter(|line| !line.trim().is_empty()).enumerate() {
match RunManifest::from_canonical_json(text) {
Ok(receipt) => receipts.push(receipt),
Err(_) => {
return format!(
"{{\"ok\":false,\"error\":\"receipt {} is not parseable\"}}",
line + 1
)
}
}
}
let report = walk_chain(&receipts);
let nodes = report
.nodes
.iter()
.map(|node| {