Crates.io | simple-si-units-core |
lib.rs | simple-si-units-core |
version | 1.0.1 |
source | src |
created_at | 2022-10-31 04:20:09.052124 |
updated_at | 2023-04-28 10:24:05.649004 |
description | This is the shared dependencies for crate simple-si-units |
homepage | https://github.com/DrPlantabyte/simple-si-units |
repository | https://github.com/DrPlantabyte/simple-si-units |
max_upload_size | |
id | 701877 |
size | 4,988 |
This crate exists to support the simple-si-units. Please go there for more information.
Crate simple-si-units-core exports the following:
This is an ergonomic trait bundle that combines the following:
Thus you can use this trait as part of a struct or function template definition, like this:
use simple_si_units_core::NumLike;
pub struct MyUnit<DT: NumLike> {
v: DT,
}
impl<DT: NumLike> std::ops::Add<Self> for MyUnit<DT> {
type Output = Self;
fn add(self, rhs: Self) -> Self::Output {
return Self { v: self.v + rhs.v };
}
}
impl<DT: NumLike> std::ops::Sub<Self> for MyUnit<DT> {
type Output = Self;
fn sub(self, rhs: Self) -> Self::Output {
return Self { v: self.v - rhs.v };
}
}
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.