Closed
Description
It would be nice if rust-analyzer could omit the type hint for infallible constructors, for example
let mut builder = MyUsefulThingyBuilder::new();
and maybe for fallible constructors in conjunction with the ?
operator too:
let thing = AnotherPrettyLongType::new(arg_a, arg_b)?;
as the type hints can cause the actual expression to go off screen and don't add anything in these cases. I'm not entirely certain what would be good criteria for considering something a constructor, but as a conservative approach only functions returning Self
, Option<Self>
or Result<Self, E>
could be considered. Although IMHO it would be nice for conversions to also not receive type hints if invoked like a constructor:
let x = Type::from(something);
let y = Type::try_from(something)?;