Uh oh!
There was an error while loading. Please reload this page.
Add Located::start, Located::end and impl Deref - #4929
Conversation
MichaReiser
commented
Apr 26, 2023
Thank you for chiming in on the PR, suggesting to upstream these changes and merging them so quickly. It's great fun contributing to RustPython thanks to you :) |
DimitrisJim
commented
Apr 26, 2023
I'd slightly push back on Deref here, docs boldly state it should only be implemented on smart pointer types but we might already be doing it in other places so 😄 |
We can undo the change if you feel strongly about. The term smart-pointer isn't well defined and there's ongoing discussion to re-phrase or even remove the section rust-lang/rust#91004. The way I think about it is that |
DimitrisJim
commented
Apr 26, 2023
I definitely do not feel that strongly! |
youknowone
commented
Apr 27, 2023
Maybe it can be anti-pattern, but we already depends on a lot for Deref for thin wrappers. And it is abused a lot in many projects 😂 . Replacing them to traits will be possible but will be painful. I hope rust have a similar features allows method call for wrappers but disallow @MichaReiser Thank you so much for paying attention to keep unified code base. You are most welcome! |
jmaargh
commented
Oct 21, 2023
FYI: Some better guidance on when and when not to |
This is a follow-up to #4192 and is motivated by the discussions in astral-sh#4
The PR adds the
startandendmethods toLocatedthat return a node's start or end location. Theendmethod falls back to returninglocationifend_locationisNone.The PR further implements
DerefforLocatedso that the node's fields and methods can be accessed directly: You can writelocated.fieldinstead oflocated.node.field