-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
It currently isn't possible to use `#[derive(Mul)]` to implement multiplication with itself AND with a scalar at the same time. Example: ```rust fn without_forward() { #[derive(Clone, Copy, Mul)] pub struct Vec2 { pub x: f32, pub y: f32, } let a = Vec2 { x: 1.0, y: 2.0 }; let c = a * Vec2 { x: 1.0, y: 1.0 }; // ❌ Doesn't work let d = a * 2.0; // ✔️ Works } fn with_forward() { #[derive(Clone, Copy, Mul)] #[mul(forward)] pub struct Vec2 { pub x: f32, pub y: f32, } let a = Vec2 { x: 1.0, y: 2.0 }; let c = a * Vec2 { x: 1.0, y: 1.0 }; // ✔️ Works let d = a * 2.0; // ❌ Doesn't work } ``` With this commit, you can have both: ```rust fn with_forward_and_scalar() { #[derive(Clone, Copy, Mul)] #[mul(forward_and_scalar)] pub struct Vec2 { pub x: f32, pub y: f32, } let a = Vec2 { x: 1.0, y: 2.0 }; let c = a * Vec2 { x: 1.0, y: 1.0 }; // ✔️ Works let d = a * 2.0; // ✔️ Works } ```
- Loading branch information
1 parent
1b0e166
commit 53f4749
Showing
3 changed files
with
50 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters