>>107591262
In idiomatic Rust this is just
fn solve(input: &str) -> [u64; 2] {
let [width, mut right] = array::repeat(input.find('\n').unwrap());
let height = input.len() / (width + 1);
let get = |x, y| char::from(input.as_bytes()[y * (width + 1) + x]);
let num = |acc, x, y| get(x, y).to_digit(10).map_or(acc, |d| acc * 10 + u64::from(d));
(0..width).rev().filter(|&x| get(x, height - 1) != ' ').fold([0; 2], |[a, b], left| {
let op = get(left, height - 1) as u8 & 1;
let (op, init) = ([Mul::mul, Add::add][usize::from(op)], 1 - u64::from(op));
let rows = (0..height - 1).map(move |y| (left..right).fold(0, |acc, x| num(acc, x, y)));
let cols = (left..right).map(|x| (0..height - 1).fold(0, |acc, y| num(acc, x, y)));
right = left.wrapping_sub(1);
[a + rows.fold(init, op), b + cols.fold(init, op)]
})
}