Skip to content
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

Add Complex::powi and assorted Pow impls #56

Merged
merged 2 commits into from
Jun 6, 2019
Merged

Conversation

cuviper
Copy link
Member

@cuviper cuviper commented Jun 4, 2019

Closes #18.

@cuviper
Copy link
Member Author

cuviper commented Jun 6, 2019

The CI failure is legit, I neglected no-std support.

However, this is annoying, because adding blanket T: Float impls gated on a feature is technically a breaking change! Actually, that makes this PR a breaking change already, because someone could technically have this for their own custom F type already:

impl Pow<F> for Complex<F> {
    type Output = Complex<F>;

    fn pow(self, exp: F) -> Self::Output {
        // ...
    }
}

The blanket powc should be OK though (with std), because a third party can't write this:

impl Pow<Complex<F>> for Complex<F> {
    type Output = Complex<F>;

    fn pow(self, exp: Self) -> Self::Output {
        //...
    }
}
error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
  --> src/lib.rs:35:1
   |
35 | impl Pow<Complex<F>> for Complex<F> {
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate
   |
   = note: the impl does not reference only types defined in this crate
   = note: define and implement a trait or new type instead

We also can't have a blanket impl `Pow<T>`, as it's a breaking change.
Instead, we add `Pow<f32>` and `Pow<f64>` where those are `Into<T>`.
@cuviper
Copy link
Member Author

cuviper commented Jun 6, 2019

bors r+

bors bot added a commit that referenced this pull request Jun 6, 2019
56: Add Complex::powi and assorted Pow impls r=cuviper a=cuviper

Closes #18.

Co-authored-by: Josh Stone <[email protected]>
@bors
Copy link
Contributor

bors bot commented Jun 6, 2019

Build succeeded

@bors bors bot merged commit c3173f7 into rust-num:master Jun 6, 2019
@cuviper cuviper deleted the pow branch February 6, 2024 23:36
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.

Implement Pow for Complex
1 participant