diff --git a/fixed_wide/Cargo.lock b/fixed_wide/Cargo.lock index ff09daa..1f6a13a 100644 --- a/fixed_wide/Cargo.lock +++ b/fixed_wide/Cargo.lock @@ -21,6 +21,7 @@ dependencies = [ "arrayvec", "bnum", "paste", + "ratio_ops", ] [[package]] @@ -28,3 +29,7 @@ name = "paste" version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" + +[[package]] +name = "ratio_ops" +version = "0.1.0" diff --git a/fixed_wide/Cargo.toml b/fixed_wide/Cargo.toml index f24c634..7b025ab 100644 --- a/fixed_wide/Cargo.toml +++ b/fixed_wide/Cargo.toml @@ -4,8 +4,8 @@ version = "0.1.0" edition = "2021" [features] -default=["ratio","zeroes","wide-mul"] -ratio=[] +default=["deferred-division","zeroes","wide-mul"] +deferred-division=["dep:ratio_ops"] wide-mul=[] zeroes=["dep:arrayvec"] @@ -13,3 +13,4 @@ zeroes=["dep:arrayvec"] bnum = "0.11.0" arrayvec = { version = "0.7.6", optional = true } paste = "1.0.15" +ratio_ops = { path = "../ratio_ops", optional = true } diff --git a/fixed_wide/src/fixed.rs b/fixed_wide/src/fixed.rs index 2e75e08..906ce49 100644 --- a/fixed_wide/src/fixed.rs +++ b/fixed_wide/src/fixed.rs @@ -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); }; } @@ -273,11 +273,11 @@ impl_multiplicative_assign_operator!( Fixed, MulAssign, mul_assign ); impl_multiplicative_operator!( Fixed, Mul, mul, Self ); impl_multiplicative_assign_operator!( Fixed, DivAssign, div_assign ); impl_multiplicative_operator!( Fixed, Div, div, Self ); -#[cfg(feature="ratio")] +#[cfg(feature="deferred-division")] impl core::ops::Div> for Fixed{ - type Output=crate::ratio::Ratio,Fixed>; + type Output=ratio_ops::ratio::Ratio,Fixed>; fn div(self, other: Fixed)->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> for Fixed<$lhs,{$lhs*32}>{ type Output=Fixed<{$lhs+$rhs},{($lhs+$rhs)*32}>; fn div(self, other: Fixed<$rhs,{$rhs*32}>)->Self::Output{ diff --git a/fixed_wide/src/lib.rs b/fixed_wide/src/lib.rs index eee0ec3..8767a20 100644 --- a/fixed_wide/src/lib.rs +++ b/fixed_wide/src/lib.rs @@ -3,8 +3,6 @@ pub mod types; #[cfg(feature="zeroes")] pub mod zeroes; -#[cfg(feature="ratio")] -pub mod ratio; #[cfg(test)] mod tests; diff --git a/linear_ops/Cargo.lock b/linear_ops/Cargo.lock index 4e0f92e..d88a4c6 100644 --- a/linear_ops/Cargo.lock +++ b/linear_ops/Cargo.lock @@ -21,10 +21,11 @@ dependencies = [ "arrayvec", "bnum", "paste", + "ratio_ops", ] [[package]] -name = "lin_ops" +name = "linear_ops" version = "0.1.0" dependencies = [ "fixed_wide", @@ -35,3 +36,7 @@ name = "paste" version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" + +[[package]] +name = "ratio_ops" +version = "0.1.0" diff --git a/ratio_ops/.gitignore b/ratio_ops/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/ratio_ops/.gitignore @@ -0,0 +1 @@ +/target diff --git a/ratio_ops/Cargo.lock b/ratio_ops/Cargo.lock new file mode 100644 index 0000000..a45b452 --- /dev/null +++ b/ratio_ops/Cargo.lock @@ -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" diff --git a/ratio_ops/Cargo.toml b/ratio_ops/Cargo.toml new file mode 100644 index 0000000..d7e0e92 --- /dev/null +++ b/ratio_ops/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "ratio_ops" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/ratio_ops/src/lib.rs b/ratio_ops/src/lib.rs new file mode 100644 index 0000000..96b877a --- /dev/null +++ b/ratio_ops/src/lib.rs @@ -0,0 +1 @@ +pub mod ratio; diff --git a/fixed_wide/src/ratio.rs b/ratio_ops/src/ratio.rs similarity index 100% rename from fixed_wide/src/ratio.rs rename to ratio_ops/src/ratio.rs