[rust] add node_ext module with full_name methods for constant nodes#3887
[rust] add node_ext module with full_name methods for constant nodes#3887
node_ext module with full_name methods for constant nodes#3887Conversation
node_ext module with full_name methods for constant nodesnode_ext module with full_name methods for constant nodes
Port Ruby's `node_ext.rb` functionality to Rust bindings, providing `full_name` and `full_name_parts` methods for `ConstantReadNode`, `ConstantWriteNode`, `ConstantTargetNode`, `ConstantPathNode`, and `ConstantPathTargetNode`. Co-Authored-By: Claude Opus 4.5 <[email protected]>
ed95c4e to
f3f9590
Compare
rust/ruby-prism/src/node_ext.rs
Outdated
There was a problem hiding this comment.
Why copy on write here?
rust/ruby-prism/src/node_ext.rs
Outdated
There was a problem hiding this comment.
I don't feel great about utf8 here, it's not guaranteed by the parser (there are ~90 encodings supported).
Address review feedback: stop assuming UTF-8 encoding since the parser supports ~90 encodings. Return &[u8] / Vec<u8> instead of Cow<str> / String to avoid silently corrupting non-UTF-8 data via from_utf8_lossy. Co-Authored-By: Claude Opus 4.6 <[email protected]>
|
Thanks for the review!
The
Agreed. I've updated the PR to return raw bytes ( |
Summary
node_ext.rbfunctionality to Rust bindingsfull_nameandfull_name_partsmethods forConstantReadNode,ConstantWriteNode,ConstantTargetNode,ConstantPathNode, andConstantPathTargetNodeConstantPathErrorenum for error handlingTest Coverage
Rust bindings include 11 unit tests compared to Ruby's 8 tests. Additional coverage includes:
ConstantWriteNode(not tested in Ruby)ConstantTargetNode(not tested in Ruby)MissingNodeserror case (not tested in Ruby)Public API Changes (cargo-public-api)
Test plan
bundle exec rake cargo:testpassesbundle exec rake cargo:lintpasses🤖 Generated with Claude Code