-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
334 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "nyar-number" | ||
version = "0.3.2" | ||
version = "0.3.3" | ||
authors = ["Aster <[email protected]>"] | ||
description = "Numeric types with GC optimization" | ||
repository = "https://github.com/nyar-vm/nyar-prime" | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
use super::*; | ||
|
||
impl ToPrimitive for NyarDecimal { | ||
fn to_isize(&self) -> Option<isize> { | ||
self.delegate().to_isize() | ||
} | ||
|
||
fn to_i8(&self) -> Option<i8> { | ||
self.delegate().to_i8() | ||
} | ||
|
||
fn to_i16(&self) -> Option<i16> { | ||
self.delegate().to_i16() | ||
} | ||
|
||
fn to_i32(&self) -> Option<i32> { | ||
self.delegate().to_i32() | ||
} | ||
|
||
fn to_i64(&self) -> Option<i64> { | ||
self.delegate().to_i64() | ||
} | ||
|
||
fn to_i128(&self) -> Option<i128> { | ||
self.delegate().to_i128() | ||
} | ||
|
||
fn to_usize(&self) -> Option<usize> { | ||
self.delegate().to_usize() | ||
} | ||
|
||
fn to_u8(&self) -> Option<u8> { | ||
self.delegate().to_u8() | ||
} | ||
|
||
fn to_u16(&self) -> Option<u16> { | ||
self.delegate().to_u16() | ||
} | ||
|
||
fn to_u32(&self) -> Option<u32> { | ||
self.delegate().to_u32() | ||
} | ||
|
||
fn to_u64(&self) -> Option<u64> { | ||
self.delegate().to_u64() | ||
} | ||
|
||
fn to_u128(&self) -> Option<u128> { | ||
self.delegate().to_u128() | ||
} | ||
|
||
fn to_f32(&self) -> Option<f32> { | ||
self.delegate().to_f32() | ||
} | ||
|
||
fn to_f64(&self) -> Option<f64> { | ||
self.delegate().to_f64() | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ use std::{ | |
|
||
mod arith; | ||
mod from; | ||
mod into; | ||
|
||
#[cfg(feature = "serde")] | ||
mod der; | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
use super::*; | ||
|
||
impl ToPrimitive for NyarInteger { | ||
fn to_isize(&self) -> Option<isize> { | ||
todo!() | ||
} | ||
|
||
fn to_i8(&self) -> Option<i8> { | ||
todo!() | ||
} | ||
|
||
fn to_i16(&self) -> Option<i16> { | ||
todo!() | ||
} | ||
|
||
fn to_i32(&self) -> Option<i32> { | ||
todo!() | ||
} | ||
|
||
fn to_i64(&self) -> Option<i64> { | ||
todo!() | ||
} | ||
|
||
fn to_i128(&self) -> Option<i128> { | ||
todo!() | ||
} | ||
|
||
fn to_usize(&self) -> Option<usize> { | ||
todo!() | ||
} | ||
|
||
fn to_u8(&self) -> Option<u8> { | ||
todo!() | ||
} | ||
|
||
fn to_u16(&self) -> Option<u16> { | ||
todo!() | ||
} | ||
|
||
fn to_u32(&self) -> Option<u32> { | ||
todo!() | ||
} | ||
|
||
fn to_u64(&self) -> Option<u64> { | ||
todo!() | ||
} | ||
|
||
fn to_u128(&self) -> Option<u128> { | ||
todo!() | ||
} | ||
|
||
fn to_f32(&self) -> Option<f32> { | ||
todo!() | ||
} | ||
|
||
fn to_f64(&self) -> Option<f64> { | ||
todo!() | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
use super::*; | ||
use num::ToPrimitive; | ||
|
||
impl ToPrimitive for NyarReal { | ||
/// Used to act as an array index | ||
fn to_isize(&self) -> Option<isize> { | ||
match self { | ||
NyarReal::Rational(v) => { | ||
if v.denominator.get().is_one() { | ||
v.numerator.get().to_isize() | ||
} | ||
else { | ||
None | ||
} | ||
} | ||
NyarReal::Decimal(_) => None, | ||
} | ||
} | ||
|
||
fn to_i8(&self) -> Option<i8> { | ||
todo!() | ||
} | ||
|
||
fn to_i16(&self) -> Option<i16> { | ||
todo!() | ||
} | ||
|
||
fn to_i32(&self) -> Option<i32> { | ||
todo!() | ||
} | ||
|
||
fn to_i64(&self) -> Option<i64> { | ||
todo!() | ||
} | ||
|
||
fn to_i128(&self) -> Option<i128> { | ||
todo!() | ||
} | ||
/// Used to act as an array index | ||
fn to_usize(&self) -> Option<usize> { | ||
match self { | ||
NyarReal::Rational(v) => { | ||
if v.denominator.get().is_one() { | ||
v.numerator.get().to_usize() | ||
} | ||
else { | ||
None | ||
} | ||
} | ||
NyarReal::Decimal(_) => None, | ||
} | ||
} | ||
|
||
fn to_u8(&self) -> Option<u8> { | ||
todo!() | ||
} | ||
|
||
fn to_u16(&self) -> Option<u16> { | ||
todo!() | ||
} | ||
|
||
fn to_u32(&self) -> Option<u32> { | ||
todo!() | ||
} | ||
|
||
fn to_u64(&self) -> Option<u64> { | ||
todo!() | ||
} | ||
|
||
fn to_u128(&self) -> Option<u128> { | ||
todo!() | ||
} | ||
|
||
fn to_f32(&self) -> Option<f32> { | ||
match self { | ||
NyarReal::Rational(v) => v.to_f32(), | ||
NyarReal::Decimal(v) => v.to_f32(), | ||
} | ||
} | ||
|
||
fn to_f64(&self) -> Option<f64> { | ||
match self { | ||
NyarReal::Rational(v) => v.to_f64(), | ||
NyarReal::Decimal(v) => v.to_f64(), | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
use super::*; | ||
|
||
impl ToPrimitive for NyarRational { | ||
fn to_isize(&self) -> Option<isize> { | ||
self.delegate().to_isize() | ||
} | ||
|
||
fn to_i8(&self) -> Option<i8> { | ||
self.delegate().to_i8() | ||
} | ||
|
||
fn to_i16(&self) -> Option<i16> { | ||
self.delegate().to_i16() | ||
} | ||
|
||
fn to_i32(&self) -> Option<i32> { | ||
self.delegate().to_i32() | ||
} | ||
|
||
fn to_i64(&self) -> Option<i64> { | ||
self.delegate().to_i64() | ||
} | ||
|
||
fn to_i128(&self) -> Option<i128> { | ||
self.delegate().to_i128() | ||
} | ||
|
||
fn to_usize(&self) -> Option<usize> { | ||
self.delegate().to_usize() | ||
} | ||
|
||
fn to_u8(&self) -> Option<u8> { | ||
self.delegate().to_u8() | ||
} | ||
|
||
fn to_u16(&self) -> Option<u16> { | ||
self.delegate().to_u16() | ||
} | ||
|
||
fn to_u32(&self) -> Option<u32> { | ||
self.delegate().to_u32() | ||
} | ||
|
||
fn to_u64(&self) -> Option<u64> { | ||
self.delegate().to_u64() | ||
} | ||
|
||
fn to_u128(&self) -> Option<u128> { | ||
self.delegate().to_u128() | ||
} | ||
|
||
fn to_f32(&self) -> Option<f32> { | ||
self.delegate().to_f32() | ||
} | ||
|
||
fn to_f64(&self) -> Option<f64> { | ||
self.delegate().to_f64() | ||
} | ||
} |
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
Oops, something went wrong.