lib

Core libraries for Radroots
git clone https://radroots.dev/git/lib.git
Log | Files | Refs | README | LICENSE

commit 63708da24f6f5216803f680d330c1691cba8173d
parent d3912855ffe51580362696e8b76029dce3e222e5
Author: triesap <tyson@radroots.org>
Date:   Sun, 15 Feb 2026 17:51:01 +0000

core: apply cargo fmt

Diffstat:
Mcore/src/currency.rs | 4++--
Mcore/src/decimal.rs | 4++--
Mcore/src/discount.rs | 14++++++++++----
Mcore/src/lib.rs | 6+++---
Mcore/src/quantity.rs | 6+++---
Mcore/src/serde_ext.rs | 4++--
Mcore/src/unit.rs | 9++++++---
Mcore/tests/discount.rs | 4+++-
8 files changed, 31 insertions(+), 20 deletions(-)

diff --git a/core/src/currency.rs b/core/src/currency.rs @@ -1,11 +1,11 @@ use core::fmt; use core::str::FromStr; +#[cfg(all(feature = "serde", not(feature = "std")))] +use alloc::string::String; #[cfg(feature = "serde")] #[cfg(feature = "std")] use std::string::String; -#[cfg(all(feature = "serde", not(feature = "std")))] -use alloc::string::String; #[cfg(feature = "serde")] use serde::{Deserialize, Deserializer, Serialize, Serializer, de::Error as DeError}; diff --git a/core/src/decimal.rs b/core/src/decimal.rs @@ -4,10 +4,10 @@ use core::str::FromStr; use rust_decimal::Decimal; use rust_decimal::prelude::ToPrimitive; -#[cfg(not(feature = "std"))] -use alloc::{format, string::ToString}; #[cfg(all(feature = "serde", not(feature = "std")))] use alloc::string::String; +#[cfg(not(feature = "std"))] +use alloc::{format, string::ToString}; #[cfg(feature = "serde")] use serde::{Deserialize, Deserializer, Serialize, Serializer, de::Error as DeError}; diff --git a/core/src/discount.rs b/core/src/discount.rs @@ -1,7 +1,7 @@ -#[cfg(feature = "std")] -use std::string::String; #[cfg(not(feature = "std"))] use alloc::string::String; +#[cfg(feature = "std")] +use std::string::String; #[cfg_attr(feature = "typeshare", typeshare::typeshare)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] @@ -15,7 +15,10 @@ pub enum RadrootsCoreDiscountScope { #[cfg_attr(feature = "typeshare", typeshare::typeshare)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug, PartialEq, Eq)] -#[cfg_attr(feature = "serde", serde(rename_all = "snake_case", tag = "kind", content = "amount"))] +#[cfg_attr( + feature = "serde", + serde(rename_all = "snake_case", tag = "kind", content = "amount") +)] pub enum RadrootsCoreDiscountThreshold { BinCount { bin_id: String, min: u32 }, OrderQuantity { min: crate::RadrootsCoreQuantity }, @@ -24,7 +27,10 @@ pub enum RadrootsCoreDiscountThreshold { #[cfg_attr(feature = "typeshare", typeshare::typeshare)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug, PartialEq, Eq)] -#[cfg_attr(feature = "serde", serde(rename_all = "snake_case", tag = "kind", content = "amount"))] +#[cfg_attr( + feature = "serde", + serde(rename_all = "snake_case", tag = "kind", content = "amount") +)] pub enum RadrootsCoreDiscountValue { MoneyPerBin(crate::RadrootsCoreMoney), Percent(crate::RadrootsCorePercent), diff --git a/core/src/lib.rs b/core/src/lib.rs @@ -27,7 +27,7 @@ pub use quantity_price::{ RadrootsCoreQuantityPrice, RadrootsCoreQuantityPriceError, RadrootsCoreQuantityPriceOps, }; pub use unit::{ - convert_mass_decimal, convert_unit_decimal, convert_volume_decimal, parse_mass_unit, - parse_volume_unit, RadrootsCoreUnit, RadrootsCoreUnitConvertError, - RadrootsCoreUnitDimension, RadrootsCoreUnitParseError, + RadrootsCoreUnit, RadrootsCoreUnitConvertError, RadrootsCoreUnitDimension, + RadrootsCoreUnitParseError, convert_mass_decimal, convert_unit_decimal, convert_volume_decimal, + parse_mass_unit, parse_volume_unit, }; diff --git a/core/src/quantity.rs b/core/src/quantity.rs @@ -1,12 +1,12 @@ use core::fmt; use crate::RadrootsCoreDecimal; -use crate::unit::{convert_unit_decimal, RadrootsCoreUnit, RadrootsCoreUnitConvertError}; +use crate::unit::{RadrootsCoreUnit, RadrootsCoreUnitConvertError, convert_unit_decimal}; -#[cfg(feature = "std")] -use std::string::String; #[cfg(not(feature = "std"))] use alloc::string::String; +#[cfg(feature = "std")] +use std::string::String; #[cfg_attr(feature = "typeshare", typeshare::typeshare)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] diff --git a/core/src/serde_ext.rs b/core/src/serde_ext.rs @@ -1,9 +1,9 @@ #![cfg(feature = "serde")] -#[cfg(feature = "std")] -use std::string::String; #[cfg(not(feature = "std"))] use alloc::string::{String, ToString}; +#[cfg(feature = "std")] +use std::string::String; use serde::{Deserialize, Deserializer, Serializer, de::Error as DeError}; diff --git a/core/src/unit.rs b/core/src/unit.rs @@ -2,11 +2,11 @@ use core::fmt; use core::str::FromStr; use rust_decimal_macros::dec; +#[cfg(all(feature = "serde", not(feature = "std")))] +use alloc::string::String; #[cfg(feature = "serde")] #[cfg(feature = "std")] use std::string::String; -#[cfg(all(feature = "serde", not(feature = "std")))] -use alloc::string::String; #[cfg(feature = "serde")] use serde::{Deserialize, Deserializer, Serialize, Serializer, de::Error as DeError}; @@ -142,7 +142,10 @@ impl fmt::Display for RadrootsCoreUnitConvertError { write!(f, "unit conversion requires volume units: {from} -> {to}") } RadrootsCoreUnitConvertError::NotConvertibleUnits { from, to } => { - write!(f, "unit conversion requires matching dimensions: {from} -> {to}") + write!( + f, + "unit conversion requires matching dimensions: {from} -> {to}" + ) } } } diff --git a/core/tests/discount.rs b/core/tests/discount.rs @@ -36,7 +36,9 @@ fn is_non_negative_validates_discount_shapes() { let d = RadrootsCoreDiscount { scope: RadrootsCoreDiscountScope::OrderTotal, - threshold: RadrootsCoreDiscountThreshold::OrderQuantity { min: qty_pos.clone() }, + threshold: RadrootsCoreDiscountThreshold::OrderQuantity { + min: qty_pos.clone(), + }, value: RadrootsCoreDiscountValue::Percent(pct_pos.clone()), }; assert!(d.is_non_negative());