Skip to content

Conversation

A4-Tacks
Copy link
Contributor

Generate inverse ops implement.

Example

struct Foo(i32);
impl core::ops::Add<i32> $0for Foo {
    type Output = i32;

    fn add(self, rhs: i32) -> Self::Output {
        self.0 + rhs
    }
}

->

struct Foo(i32);
impl core::ops::Add<Foo> for i32 {
    type Output = i32;

    fn add(self, rhs: Foo) -> Self::Output {
        rhs.0 + self
    }
}

impl core::ops::Add<i32> for Foo {
    type Output = i32;

    fn add(self, rhs: i32) -> Self::Output {
        self.0 + rhs
    }
}

Generate inverse ops implement.

Example
---
```rust
struct Foo(i32);
impl core::ops::Add<i32> $0for Foo {
    type Output = i32;

    fn add(self, rhs: i32) -> Self::Output {
        self.0 + rhs
    }
}
```
->
```rust
struct Foo(i32);
impl core::ops::Add<Foo> for i32 {
    type Output = i32;

    fn add(self, rhs: Foo) -> Self::Output {
        rhs.0 + self
    }
}

impl core::ops::Add<i32> for Foo {
    type Output = i32;

    fn add(self, rhs: i32) -> Self::Output {
        self.0 + rhs
    }
}
```
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants