-
Notifications
You must be signed in to change notification settings - Fork 106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Named accessor ops #965
Named accessor ops #965
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #965 +/- ##
==========================================
+ Coverage 81.43% 81.53% +0.09%
==========================================
Files 97 98 +1
Lines 23877 25361 +1484
==========================================
+ Hits 19445 20678 +1233
- Misses 4432 4683 +251 ☔ View full report in Codecov by Sentry. |
// All setters must start with "__set_". | ||
let key = key.strip_prefix("__set_").expect("Invalid setter name"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a particular reason for this? Why don't getters require to start with __get_
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is to allow for getter and setters to be defined with the same name. Only one needs to be changed to avoid name collision
#[getter]
fn x() {}
#[setter]
fn x() {} // op2 automatically converts this to __set_x to avoid name collision
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice, LGTM!
Implement get/set accessors for object wrap ops.