Rust can not partially infer types?

fn test<A, B>(b: B) -> usize {
    std::mem::size_of::<A>() + std::mem::size_of::<B>()
}
fn main() {
    test::<u32>(4);
}

Shouldn't Rust see in this case that A was explicitly named and that B can be inferred?

fn test<A, B>(b: B) -> usize {
    std::mem::size_of::<A>() + std::mem::size_of::<B>()
}
fn main() {
    test::<u32, _>(4);
}

Rust doesn't have partial application.

2 Likes

This has been proposed, though: RFC for allowing eliding more type parameters. by huonw · Pull Request #1196 · rust-lang/rfcs · GitHub