Skip to content

Commit

Permalink
my_is_nan method has been added
Browse files Browse the repository at this point in the history
  • Loading branch information
RomanShushakov committed Nov 2, 2022
1 parent d3029e1 commit 1cc0f3a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 18 additions & 11 deletions src/lib.rs
@@ -1,24 +1,21 @@
pub trait MyFloatTrait
{
type Other;

fn my_powi(&self, n: i32) -> Self;
fn my_sqrt(&self) -> Self;
fn my_acos(&self) -> Self;
fn my_cos(&self) -> Self;
fn my_sin(&self) -> Self;
fn my_abs(&self) -> Self;
fn my_asin(&self) -> Self;
fn my_atan2(&self, other: Self::Other) -> Self;
fn my_atan2(&self, other: &Self) -> Self;
fn my_atan(&self) -> Self;
fn my_to_degrees(&self) -> Self;
fn my_is_nan(&self) -> bool;
}


impl MyFloatTrait for f32
{
type Other = f32;

fn my_powi(&self, n: i32) -> Self
{
self.powi(n)
Expand Down Expand Up @@ -61,9 +58,9 @@ impl MyFloatTrait for f32
}


fn my_atan2(&self, other: Self::Other) -> Self
fn my_atan2(&self, other: &Self) -> Self
{
self.atan2(other)
self.atan2(*other)
}


Expand All @@ -77,13 +74,17 @@ impl MyFloatTrait for f32
{
self.to_degrees()
}


fn my_is_nan(&self) -> bool
{
self.is_nan()
}
}


impl MyFloatTrait for f64
{
type Other = f64;

fn my_powi(&self, n: i32) -> Self
{
self.powi(n)
Expand Down Expand Up @@ -126,9 +127,9 @@ impl MyFloatTrait for f64
}


fn my_atan2(&self, other: Self::Other) -> Self
fn my_atan2(&self, other: &Self) -> Self
{
self.atan2(other)
self.atan2(*other)
}


Expand All @@ -142,4 +143,10 @@ impl MyFloatTrait for f64
{
self.to_degrees()
}


fn my_is_nan(&self) -> bool
{
self.is_nan()
}
}

0 comments on commit 1cc0f3a

Please sign in to comment.