3 ms·
Hiding those awful nested statements makes you think that perhaps the code is ok when it should probably be changed to make it more readable.
by unkiwii 2y ago
Hiding those awful nested statements makes you think that perhaps the code is ok when it should probably be changed to make it more readable.
- mrweasel 2y agoThat's probably a secondary issue. The suggestion is to change how code folding is done. Most IDEs can do some type of code folding, but in this case the author is asking for it to work in a certain way. I don't think the example is all that good, because it's not the same code in both screenshots. The suggestion, as I read it, is that folding the "impl Body" shouldn't collapse the entire thing to impl Body { ... }, but instead collapse all the functions inside it, because that's actually more useful. So you'd get impl Body { fn new(db: &dyn DefDatabasse) { ... } pub fn shrink_to_fit(&mut self) { ... } } It this was Python and you collapsed a class, then rather than getting class User(AbstractUser): ... you'd get: class User(AbstractUser): def is_manager(self): ... def get_username(self): ... It would perhaps even be a little neat if you could have a class collapsed and you'd be shown only public methods, if the language has the concept of public and private methods. To build on the "hiding awful code", I think this could help show awful API/interface design. If you have a class with a few hundred lines of code and a number of methods, then you rarely get to see all your methods listed, their signature just drowns in a sea of code. The also add doc strings, then you now have a documentation view of your own code in the IDE.