#![allow(dead_code)]
pub fn flag_words() -> Vec<u32> {
const TEXT: [u32; 6] = [0x02, 0x04, 0x10, 0x20, 0x40, 0x80];
let mut words = vec![0, TEXT.iter().sum()];
for (i, a) in TEXT.iter().enumerate() {
words.push(*a);
words.extend(TEXT[i + 1..].iter().map(|b| a | b));
}
words.sort_unstable();
words
}
pub fn microsofts(bytes: &[u8]) -> String {
String::from_utf8_lossy(bytes)
.trim_end_matches('\0')
.replace("\r\n", "\n")
}
pub fn difference(what: &str, ours: &str, theirs: &str) -> Option<String> {
if ours == theirs {
return None;
}
let line = ours
.lines()
.zip(theirs.lines())
.position(|(a, b)| a != b)
.unwrap_or(0);
Some(format!(
"{what} line {}:\n dx: {:?}\n ms: {:?}",
line + 1,
ours.lines().nth(line).unwrap_or(""),
theirs.lines().nth(line).unwrap_or("")
))
}