Become a fan of Slashdot on Facebook

 



Forgot your password?
typodupeerror

Comment Re: Rust is a waste of duplicated effort (Score 1) 83

I find the inlay hints extremely annoying and always turn them off. If I need to know the type of something, hovering works. I also think that inlay hints shouldn't be relied on, and it's sometimes good to add your own annotations. For example, no problem IMO with `let s = "something";` because there's no doubt that it's a `&str`, or `vec![0u8, 1, 2, 3, 4]` being a `Vec`. Same for `let food = 8u16;` (I don't like that the analyzer adds the redundanct `: u16` here, but at least it's consistent), and for reassignments `let x: u16 = 0; let y = x`. However: if you have `let foo = bar();` and the return type isn't explicit from `bar()`, I think it's good practice to add a type annotation - same for anywhere it's not obvious. It just makes it easier to understand your code without a language server (github, barebones vim, etc). Re: the type noise. I think a lot of this comes from generics. If your struct takes a generic, it's not impossible to have something like `Option>>`. Which on one hand is noisy and long to type. But on the other hand 1. it's crystal clear what it's representing - there's no misunderstanding the nesting 2. you can always `type MyType = Option` to typedef it away if you use it often enough 3. You don't need to type it everywhere where if it's obvious, following my guidelines from above 4. There's nothing in C to compare this to since there are no generics TL;DR, I think there's a happy medium with "it's needed, type it out" "it's obvious, code readers can figure it out", and "it's not obvious, give code readers a hint", and I appreciate all three being options

Slashdot Top Deals

Any circuit design must contain at least one part which is obsolete, two parts which are unobtainable, and three parts which are still under development.

Working...