4 ms·
This isn't so bad except in the case where a developer puts off the resolving statement until later in the function, though I imagine (hope) there is almost nev
by happytoexplain 3y ago
This isn't so bad except in the case where a developer puts off the resolving statement until later in the function, though I imagine (hope) there is almost never a legitimate reason to do that.
Is it theoretically possible to split the resolution into two lines? Then, as a reader, it might not always be obvious at what point the type is fully resolved.
E.g (pseudocode, and also it makes no practical sense since you would have populated it before interrogating it).
let mut foo = HashMap::new();
print(foo.containsKey("bar")); // here we've resolved the key type
print(foo.containsValue(true)); // here we've resolved the value type
- bestouff 3y agoOf course yes.
- kibwen 3y ago> Then, as a reader, it might not always be obvious at what point the type is fully resolved. This is rarely a problem, because Rust is strict enough that it will tell you if your types aren't lining up like you think they are. And if you're using an editor with LSP support, then you can have inlay hints that reveal the types of all variables if you like.
- happytoexplain 3y ago> inlay hints that reveal the types Oh, that would go a long way to making me feel less nervous reading code like this.