I'm writing an RSS consumer that needs to hash article data for performance in ValKey.
I am processing these RSS items in a loop while I'm prototyping and I ran into a very odd bug. Some of the values fail to hash when I don't print anything else in that loop iteration. Not only that, but the entire println! macro is skipped.
Here is the code that reproduces my issue:
for item in chn.items.into_iter() {
//println!("{}", item.guid().unwrap().value());
println!("{}", item.title().unwrap());
let mut hasher = AHasher::default();
let b = item.guid().unwrap().value().as_bytes();
assert!(!b.is_empty());
hasher.write(b);
println!("Hash: {:?} \n", hasher.finish());
//println!("end of item");
}
And here is the output:
Trump Has Said âNo Exceptionsâ to His Tariffs. Will That Last?
Hash: 1057710333405281575
Elon Musk and Marco Rubio Share Awkward Social Media Embrace After White House Confrontation
Hash: 11924599548058660221
Trump, With More Honey Than Vinegar, Cements an Iron Grip on Republicans
Trump Seeks to Expel a Green Card Holder, Mahmoud Khalil, Over Student Protests
Ukraine Must Cede Territory in Any Peace Deal, Rubio Says
Hash: 1523441670221523159
Russian Forces Depleted and Stalling on Eastern Front, Ukraine Says
Hash: 18412823308182799818
Here is the code that works properly:
for item in chn.items.into_iter() {
//println!("{}", item.guid().unwrap().value());
println!("{}", item.title().unwrap());
let mut hasher = AHasher::default();
let b = item.guid().unwrap().value().as_bytes();
assert!(!b.is_empty());
hasher.write(b);
println!("Hash: {:?}", hasher.finish());
println!("end of item");
}
And here is the output:
Trump Has Said âNo Exceptionsâ to His Tariffs. Will That Last?
Hash: 12285485996232063774
end of item
Elon Musk and Marco Rubio Share Awkward Social Media Embrace After White House Confrontation
Hash: 7187227338832286181
end of item
Trump, With More Honey Than Vinegar, Cements an Iron Grip on Republicans
Hash: 9681329398627943619
end of item
Ukraine Must Cede Territory in Any Peace Deal, Rubio Says
Hash: 7169634133579351125
end of item
Russian Forces Depleted and Stalling on Eastern Front, Ukraine Says
Hash: 14521009450892122283
end of item
I welcome any ideas, because frankly this is baffling.