Open
Description
I tried this code:
use std::marker::PhantomData;
fn test_good() -> Builder<String> {
// this compiles
Builder::default().with_func(|s| drop(s))
}
fn test_bad() -> Builder<String> {
// error[E0282]: type annotations needed
Builder::default().with_func(|s| drop(s.len()))
}
#[derive(Default)]
pub struct Builder<Foo>(PhantomData<Foo>);
impl<Foo> Builder<Foo> {
fn with_func(self, _: impl Fn(Foo)) -> Self {
self
}
}
I expect this to compile, but the test_bad
function does not compile.
Meta
Rust Version: 1.86.0