Skip to content

Add more supertraits to ComplexFloat #145

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/complex_float.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Keeps us from accidentally creating a recursive impl rather than a real one.
#![deny(unconditional_recursion)]

use core::ops::Neg;
use core::ops::{Add, Div, Mul, Neg, Rem, Sub};

use num_traits::{Float, FloatConst, Num, NumCast};

Expand All @@ -25,7 +25,19 @@ mod private {
///
/// This trait is sealed to prevent it from being implemented by anything other
/// than floating point scalars and [Complex] floats.
pub trait ComplexFloat: Num + NumCast + Copy + Neg<Output = Self> + private::Seal {
pub trait ComplexFloat:
Num
+ NumCast
+ Copy
+ Neg<Output = Self>
+ From<<Self as ComplexFloat>::Real>
+ Add<<Self as ComplexFloat>::Real, Output = Self>
+ Sub<<Self as ComplexFloat>::Real, Output = Self>
+ Mul<<Self as ComplexFloat>::Real, Output = Self>
+ Div<<Self as ComplexFloat>::Real, Output = Self>
+ Rem<<Self as ComplexFloat>::Real, Output = Self>
+ private::Seal
{
/// The type used to represent the real coefficients of this complex number.
type Real: Float + FloatConst;

Expand Down