macros public
parent
dc88a4b79a
commit
292f61d582
|
@ -1,4 +1,4 @@
|
|||
[package]
|
||||
name = "unidades"
|
||||
version = "1.1.2"
|
||||
version = "1.1.3"
|
||||
edition = "2021"
|
||||
|
|
|
@ -4,6 +4,8 @@ pub mod dimensions;
|
|||
pub mod units;
|
||||
pub mod prefixes;
|
||||
pub mod measurement;
|
||||
pub use units::unit;
|
||||
pub use prefixes::prefix_group;
|
||||
|
||||
pub trait Unit<D> {
|
||||
fn new(v: f64) -> D;
|
||||
|
|
|
@ -4,7 +4,8 @@ use crate::{
|
|||
};
|
||||
use core::marker::PhantomData;
|
||||
|
||||
macro_rules! prefixes{
|
||||
#[macro_export]
|
||||
macro_rules! prefix_group{
|
||||
($(($nym: ident, $scale: expr)), *) => {
|
||||
$(
|
||||
pub struct $nym < T >(PhantomData < T >);
|
||||
|
@ -48,7 +49,9 @@ macro_rules! prefixes{
|
|||
};
|
||||
}
|
||||
|
||||
prefixes!{
|
||||
pub use prefix_group;
|
||||
|
||||
prefix_group!{
|
||||
(Quetta, 1e30),
|
||||
(Ronna, 1e27),
|
||||
(Yotta, 1e24),
|
||||
|
|
|
@ -6,6 +6,7 @@ use crate::{
|
|||
const YEAR: f64 = 31_557_600.0;
|
||||
const DAY: f64 = 60.0 * 60.0 * 24.0;
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! unit{
|
||||
($dimension: ident => $(($nym: ident, ($scale: expr, $offset: expr))), *) => {
|
||||
$(pub struct $nym; impl Unit < $dimension > for $nym {
|
||||
|
@ -22,6 +23,8 @@ macro_rules! unit{
|
|||
};
|
||||
}
|
||||
|
||||
pub use unit;
|
||||
|
||||
impl Unit<Scalar> for () {
|
||||
fn new(v: f64) -> Scalar {
|
||||
Scalar::new::<()>(v)
|
||||
|
|
Loading…
Reference in New Issue