Cleanup
This commit is contained in:
parent
0dcb7b2722
commit
408a205e11
@ -2,6 +2,12 @@
|
||||
name = "units"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
description = "Si units for typesafe calculations"
|
||||
license = "MIT or Apache-2.0"
|
||||
repository = "https://git.mkaenner.de/max/units-rs.git"
|
||||
readme = "README.md"
|
||||
keywords = ["si", "units"]
|
||||
categories = ["Science", "Simulation"]
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
|
@ -2,8 +2,20 @@ use std::fmt::{Display, Formatter};
|
||||
|
||||
use typenum::Integer;
|
||||
|
||||
use crate::{types::*, SiUnit};
|
||||
use crate::{
|
||||
types::{
|
||||
AmperePerMeter, AmperePerSquareMeter, Coulomb, CoulombPerCubicMeter, CoulombPerKilogram,
|
||||
CoulombPerSquareMeter, CubicMeterPerKilogram, Farad, FaradPerMeter, Gray, GrayPerSecond,
|
||||
Henry, HenryPerMeter, Herz, Joule, JoulePerKelvin, JoulePerKilogramKelvin, JoulePerMole,
|
||||
JoulePerMoleKelvin, Katal, KatalPerCubicMeter, KilogramPerCubicMeter,
|
||||
KilogramPerSquareMeter, Lux, MeterPerSecond, MeterPerSquareSecond, MolePerCubicMeter,
|
||||
Newton, NewtonPerMeter, Ohm, Pascal, PascalSecond, Siemens, Tesla, Volt, VoltPerMeter,
|
||||
Watt, WattPerMeterKelvin, WattPerSquareMeter, Weber,
|
||||
},
|
||||
SiUnit,
|
||||
};
|
||||
|
||||
#[cfg(feature = "defmt")]
|
||||
macro_rules! display_unit_defmt {
|
||||
($formatter: ident, $param: ident, $symbol: literal, $e1: ident, $e2: ident, $e3: ident, $e4: ident, $e5: ident, $e6: ident) => {
|
||||
if $param::I64 != 0 {
|
||||
@ -25,6 +37,7 @@ macro_rules! display_unit_defmt {
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(feature = "defmt")]
|
||||
macro_rules! display_special_unit_defmt {
|
||||
($formatter: ident, $self: ident, $(($symbol: literal, $other: ty)),* $(,)?) => {
|
||||
$(
|
||||
@ -49,6 +62,7 @@ where
|
||||
Candela: Integer,
|
||||
T: defmt::Format + 'static,
|
||||
{
|
||||
#[allow(clippy::cognitive_complexity)]
|
||||
fn format(&self, f: defmt::Formatter<'_>) {
|
||||
defmt::write!(f, "{}", self.value);
|
||||
// derived units with special symbols
|
||||
@ -221,6 +235,8 @@ where
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use crate::types::{Ampere, Candela, Kelvin, Kilogram, Meter, Mole, Second, Unit};
|
||||
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
@ -230,6 +246,7 @@ mod test {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[allow(clippy::cognitive_complexity)]
|
||||
fn display() {
|
||||
let unit = Unit::new(2);
|
||||
let second = Second::new(2);
|
||||
|
@ -2,7 +2,6 @@ mod display;
|
||||
pub mod types;
|
||||
|
||||
use std::{
|
||||
fmt::{Display, Formatter},
|
||||
marker::PhantomData,
|
||||
ops::{
|
||||
Add, AddAssign, Deref, DerefMut, Div, DivAssign, Mul, MulAssign, Neg, Rem, RemAssign, Sub,
|
||||
@ -556,7 +555,9 @@ where
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::types::*;
|
||||
use super::types::{
|
||||
Ampere, Coulomb, CubicMeter, Meter, ReciprocalMeter, Second, SquareMeter, Unit, Volt, Watt,
|
||||
};
|
||||
use num_traits::{Num, One, Zero};
|
||||
|
||||
#[test]
|
||||
|
Loading…
Reference in New Issue
Block a user