Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@aarkegz
Copy link
Contributor

@aarkegz aarkegz commented Jan 21, 2026

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.

Copy link
Contributor

Copilot AI left a 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_args that rejects methods with receiver arguments
  • Updated both def_interface and impl_interface macros 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.

Copy link

@AsakuraMizu AsakuraMizu left a 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.

@aarkegz
Copy link
Contributor Author

aarkegz commented Jan 21, 2026

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?

@aarkegz aarkegz changed the title Reject receiver args in crate_interface traits Explicitly reject receivers and generic parameters in crate_interface methods Jan 21, 2026
@aarkegz aarkegz requested a review from Copilot January 21, 2026 16:28
Copy link
Contributor

Copilot AI left a 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.

@aarkegz aarkegz merged commit 31497e7 into main Jan 22, 2026
18 checks passed
@aarkegz aarkegz deleted the feat/disable_self branch January 22, 2026 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants