Fix build in recent Rust.

fail! -> panic!
Use generic functions instead of trait objects.