move ratio to own crate (again)

This commit is contained in:
Quaternions 2024-09-10 12:04:18 -07:00
parent fc65d0f1f4
commit 91b96e4b5d
10 changed files with 34 additions and 10 deletions

5
fixed_wide/Cargo.lock generated
View File

@ -21,6 +21,7 @@ dependencies = [
"arrayvec", "arrayvec",
"bnum", "bnum",
"paste", "paste",
"ratio_ops",
] ]
[[package]] [[package]]
@ -28,3 +29,7 @@ name = "paste"
version = "1.0.15" version = "1.0.15"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a"
[[package]]
name = "ratio_ops"
version = "0.1.0"

View File

@ -4,8 +4,8 @@ version = "0.1.0"
edition = "2021" edition = "2021"
[features] [features]
default=["ratio","zeroes","wide-mul"] default=["deferred-division","zeroes","wide-mul"]
ratio=[] deferred-division=["dep:ratio_ops"]
wide-mul=[] wide-mul=[]
zeroes=["dep:arrayvec"] zeroes=["dep:arrayvec"]
@ -13,3 +13,4 @@ zeroes=["dep:arrayvec"]
bnum = "0.11.0" bnum = "0.11.0"
arrayvec = { version = "0.7.6", optional = true } arrayvec = { version = "0.7.6", optional = true }
paste = "1.0.15" paste = "1.0.15"
ratio_ops = { path = "../ratio_ops", optional = true }

View File

@ -215,7 +215,7 @@ macro_rules! impl_divide_operator_not_const_generic {
} }
} }
} }
#[cfg(all(not(feature="wide-mul"),not(feature="ratio")))] #[cfg(all(not(feature="wide-mul"),not(feature="deferred-division")))]
impl_multiplicative_operator_not_const_generic!(($struct, $trait, $method, $output ), $width); impl_multiplicative_operator_not_const_generic!(($struct, $trait, $method, $output ), $width);
}; };
} }
@ -273,11 +273,11 @@ impl_multiplicative_assign_operator!( Fixed, MulAssign, mul_assign );
impl_multiplicative_operator!( Fixed, Mul, mul, Self ); impl_multiplicative_operator!( Fixed, Mul, mul, Self );
impl_multiplicative_assign_operator!( Fixed, DivAssign, div_assign ); impl_multiplicative_assign_operator!( Fixed, DivAssign, div_assign );
impl_multiplicative_operator!( Fixed, Div, div, Self ); impl_multiplicative_operator!( Fixed, Div, div, Self );
#[cfg(feature="ratio")] #[cfg(feature="deferred-division")]
impl<const LHS_N:usize,const LHS_F:usize,const RHS_N:usize,const RHS_F:usize> core::ops::Div<Fixed<RHS_N,RHS_F>> for Fixed<LHS_N,LHS_F>{ impl<const LHS_N:usize,const LHS_F:usize,const RHS_N:usize,const RHS_F:usize> core::ops::Div<Fixed<RHS_N,RHS_F>> for Fixed<LHS_N,LHS_F>{
type Output=crate::ratio::Ratio<Fixed<LHS_N,LHS_F>,Fixed<RHS_N,RHS_F>>; type Output=ratio_ops::ratio::Ratio<Fixed<LHS_N,LHS_F>,Fixed<RHS_N,RHS_F>>;
fn div(self, other: Fixed<RHS_N,RHS_F>)->Self::Output{ fn div(self, other: Fixed<RHS_N,RHS_F>)->Self::Output{
crate::ratio::Ratio::new(self,other) ratio_ops::ratio::Ratio::new(self,other)
} }
} }
@ -318,7 +318,7 @@ macro_rules! impl_wide_operators{
} }
} }
} }
#[cfg(not(feature="ratio"))] #[cfg(not(feature="deferred-division"))]
impl core::ops::Div<Fixed<$rhs,{$rhs*32}>> for Fixed<$lhs,{$lhs*32}>{ impl core::ops::Div<Fixed<$rhs,{$rhs*32}>> for Fixed<$lhs,{$lhs*32}>{
type Output=Fixed<{$lhs+$rhs},{($lhs+$rhs)*32}>; type Output=Fixed<{$lhs+$rhs},{($lhs+$rhs)*32}>;
fn div(self, other: Fixed<$rhs,{$rhs*32}>)->Self::Output{ fn div(self, other: Fixed<$rhs,{$rhs*32}>)->Self::Output{

View File

@ -3,8 +3,6 @@ pub mod types;
#[cfg(feature="zeroes")] #[cfg(feature="zeroes")]
pub mod zeroes; pub mod zeroes;
#[cfg(feature="ratio")]
pub mod ratio;
#[cfg(test)] #[cfg(test)]
mod tests; mod tests;

7
linear_ops/Cargo.lock generated
View File

@ -21,10 +21,11 @@ dependencies = [
"arrayvec", "arrayvec",
"bnum", "bnum",
"paste", "paste",
"ratio_ops",
] ]
[[package]] [[package]]
name = "lin_ops" name = "linear_ops"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"fixed_wide", "fixed_wide",
@ -35,3 +36,7 @@ name = "paste"
version = "1.0.15" version = "1.0.15"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a"
[[package]]
name = "ratio_ops"
version = "0.1.0"

1
ratio_ops/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/target

7
ratio_ops/Cargo.lock generated Normal file
View File

@ -0,0 +1,7 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "ratio_ops"
version = "0.1.0"

6
ratio_ops/Cargo.toml Normal file
View File

@ -0,0 +1,6 @@
[package]
name = "ratio_ops"
version = "0.1.0"
edition = "2021"
[dependencies]

1
ratio_ops/src/lib.rs Normal file
View File

@ -0,0 +1 @@
pub mod ratio;