simple-si-units-macros

Crates.iosimple-si-units-macros
lib.rssimple-si-units-macros
version1.0.1
sourcesrc
created_at2022-10-31 04:27:26.480408
updated_at2023-04-28 10:24:52.135674
descriptionThis is the procedural macro library for crate simple-si-units
homepagehttps://github.com/DrPlantabyte/simple-si-units
repositoryhttps://github.com/DrPlantabyte/simple-si-units
max_upload_size
id701882
size41,242
Chris Hall (DrPlantabyte)

documentation

https://docs.rs/simple-si-units-macros/

README

simple-si-units-core

This crate exists to support the simple-si-units. Please go there for more information.

Contents

Crate simple-si-units-macros exports the following derive macros:

Unit

This macro uses the NumLike trait from simple-si-units-core to derive all of the relevant mathematical operators for the derived struct, so long as that struct contains only a single named field. For example:

use simple_si_units_macros::UnitStruct;
use simple_si_units_core::NumLike;

#[derive(UnitStruct, Debug, Clone)]
struct HyperVelocity<T: NumLike>{
  square_meters_per_second: T
}

fn weighted_hypervel_sum<T: NumLike>(a: HyperVelocity<T>, b: HyperVelocity<T>, weight: f64) -> HyperVelocity<T>
  where T:NumLike + From<f64>
{
  return weight*a + (1.-weight)*b;
}

License

This library is open source, licensed under the Mozilla Public License version 2.0. In summary, you may include this source code as-is in both open-source and proprietary projects without requesting permission from me, but if you modify the source code from this library then you must make your modified version of this library available under an open-source license.

Commit count: 153

cargo fmt