Ergonomics question. Getting around "cannot infer type for type parameter" for optional arg

To repeat my pattern presented in this answer, a zero-sized option using an uninhabited function type appears to be an elegant solution to me. This will guaranteed not generate any non-None branches anymore.

#[inline]
fn none() -> Option<impl Fn(usize, usize, &[i16; 4]) -> Option<f64>> {
    enum Void {}
    None::<Void>.map(|void| move |_, _, _: &_| match void {})
}

(playground)


Edit 2022: This code will need slight modification to get the same zero-sized option behavior in edition 2021.

2 Likes