-
Notifications
You must be signed in to change notification settings - Fork 5
Explicitly reject receivers and generic parameters in crate_interface methods #8
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
Conversation
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.
Pull request overview
This pull request explicitly rejects receiver arguments (self, &self, &mut self) in crate_interface traits to improve API clarity and readability. Previously, receiver arguments were silently ignored, but now they are explicitly rejected with clear error messages.
Changes:
- Added validation function
clone_and_validate_argsthat rejects methods with receiver arguments - Updated both
def_interfaceandimpl_interfacemacros to use this validation - Removed all receiver parameters from test examples and documentation
- Added documentation notes explaining that only associated functions (static methods) are supported
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/lib.rs | Adds clone_and_validate_args function for validation, integrates it into both def_interface and impl_interface macros, and adds documentation with compile_fail examples |
| tests/test_crate_interface.rs | Updates all test trait and implementation methods to remove receiver parameters |
| README.md | Updates all examples and documentation to remove receiver parameters and adds a new "Things to Note" section explaining the restriction |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
AsakuraMizu
left a comment
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.
I generally agree with this, but note that this change is breaking.
Yes, so it's a little bit embarrassing that we have just released v0.2.0 . Are receivers used anywhere currently? |
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.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Currently, the receiver args (
self,&self,&mut self, etc) is allowed while not actually used in crate_interface methods. Explicitly rejecting them improves the readability and clarity of crate_interface traits.Also, generic parameters do not work on crate_interface methods, as Rust does not allow generic parameters on extern functions, this PR also introduces better compiler errors for generic parameters.