Consider a function with a type signature like this:
fn func<P: AsRef<Path>>(path: Option<P>)
Such a function might call an underlying FFI function that accepts a const char *, mapping None to NULL.
Calling that function with a None parameter doesn’t provide enough information for type inference; the compiler doesn’t know the type of P inside the Option. This typically requires an explicit None as Option<SomeType>, a type specified for func, or in the future a type ascription; all of those seem far less convenient than just saying None.
However, the function itself handles None identically regardless of the type P.
Given that, I wonder if Rust could provide some way to simplify this, and allow func(None) to work without further type information. As one possibility, what if there were a way to say “if you don’t know what type to use, and any type will do, use this one”. For instance, in the call above, the default could be Option<&Path>.
Does that seem plausible? Or, does anyone see another plausible route to support func(None) without further type information?