Rust can not partially infer types?


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

https://is.gd/6AaQZK

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


#2
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.


#3

This has been proposed, though: https://github.com/rust-lang/rfcs/pull/1196