{"id":13671974,"url":"https://github.com/iliekturtles/uom","last_synced_at":"2025-05-13T16:06:28.756Z","repository":{"id":37883411,"uuid":"61666410","full_name":"iliekturtles/uom","owner":"iliekturtles","description":"Units of measurement -- type-safe zero-cost dimensional analysis","archived":false,"fork":false,"pushed_at":"2025-02-16T20:15:04.000Z","size":1106,"stargazers_count":1065,"open_issues_count":133,"forks_count":101,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-04-08T23:11:56.826Z","etag":null,"topics":["dimensional-analysis","rust","si"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/iliekturtles.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-06-21T20:52:57.000Z","updated_at":"2025-03-30T23:10:50.000Z","dependencies_parsed_at":"2022-07-21T04:49:19.328Z","dependency_job_id":"bb7731f5-521f-479d-851f-c778b067b5f9","html_url":"https://github.com/iliekturtles/uom","commit_stats":{"total_commits":419,"total_committers":41,"mean_commits":10.21951219512195,"dds":"0.38186157517899766","last_synced_commit":"c6603db14df35581cd12ce0247dcf1b3f9bc0038"},"previous_names":[],"tags_count":42,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iliekturtles%2Fuom","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iliekturtles%2Fuom/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iliekturtles%2Fuom/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iliekturtles%2Fuom/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iliekturtles","download_url":"https://codeload.github.com/iliekturtles/uom/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250513191,"owners_count":21443175,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dimensional-analysis","rust","si"],"created_at":"2024-08-02T09:01:23.315Z","updated_at":"2025-04-23T20:41:26.844Z","avatar_url":"https://github.com/iliekturtles.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"uom\n===\n[![Github Actions](https://img.shields.io/github/actions/workflow/status/iliekturtles/uom/ci-full-test-suite.yml?branch=master)](https://github.com/iliekturtles/uom/actions)\n[![Codecov.io](https://img.shields.io/codecov/c/github/iliekturtles/uom/master)](https://codecov.io/gh/iliekturtles/uom)\n[![Rustup.rs](https://img.shields.io/badge/rustc-1.65.0%2B-orange.svg)](https://rustup.rs/)\n[![Crates.io](https://img.shields.io/crates/v/uom.svg)](https://crates.io/crates/uom)\n[![Crates.io](https://img.shields.io/crates/l/uom.svg)](https://crates.io/crates/uom)\n[![Documentation](https://img.shields.io/badge/documentation-docs.rs-blue.svg)](https://docs.rs/uom)\n\nUnits of measurement is a crate that does automatic type-safe zero-cost\n[dimensional analysis][analysis]. You can create your own systems or use the pre-built\n[International System of Units][si] (SI) which is based on the\n[International System of Quantities][isq] (ISQ) and includes numerous [quantities][quantity]\n(length, mass, time, ...) with conversion factors for even more numerous\n[measurement units][measurement] (meter, kilometer, foot, mile, ...). No more crashing your\n[climate orbiter][orbiter]!\n\n[analysis]: https://en.wikipedia.org/wiki/Dimensional_analysis\n[si]: https://jcgm.bipm.org/vim/en/1.16.html\n[isq]: https://jcgm.bipm.org/vim/en/1.6.html\n[quantity]: https://jcgm.bipm.org/vim/en/1.1.html\n[measurement]: https://jcgm.bipm.org/vim/en/1.9.html\n[orbiter]: https://en.wikipedia.org/wiki/Mars_Climate_Orbiter\n\n## Usage\n`uom` requires `rustc` 1.65.0 or later. Add this to your `Cargo.toml`:\n\n```toml\n[dependencies]\nuom = \"0.36.0\"\n```\n\nand this to your crate root:\n\n```rust\nextern crate uom;\n```\n\nThe simple example below shows how to use quantities and units as well as how `uom` stops invalid\noperations:\n\n```rust\nextern crate uom;\n\nuse uom::si::f32::*;\nuse uom::si::length::kilometer;\nuse uom::si::time::second;\n\nfn main() {\n    let length = Length::new::\u003ckilometer\u003e(5.0);\n    let time = Time::new::\u003csecond\u003e(15.0);\n    let velocity/*: Velocity*/ = length / time;\n    let _acceleration = calc_acceleration(velocity, time);\n    //let error = length + time; // error[E0308]: mismatched types\n\n    // Get a quantity value in a specific unit.\n    let time_in_nano_seconds = time.get::\u003cuom::si::time::nanosecond\u003e();\n}\n\nfn calc_acceleration(velocity: Velocity, time: Time) -\u003e Acceleration {\n    velocity / time\n}\n```\n\nSee the [examples](examples) directory for more advanced usage:\n\n * [si.rs](examples/si.rs) -- Shows how to use the pre-built SI system.\n * [base.rs](examples/base.rs) -- Shows how to create a set of `Quantity` type aliases for a\n   different set of base units. See the [Design](#design) section for implications of choosing\n   different base units.\n * [mks.rs](examples/mks.rs) -- Shows how to create a custom system of quantities.\n * [unit.rs](examples/unit.rs) -- Shows how to add new units to existing quantities in the\n   pre-build SI system.\n\n## Features\n`uom` has multiple `Cargo` features for controlling available underlying storage types, the\ninclusion of the pre-built [International System of Units][si] (SI), support for [Serde][serde],\nand `no_std` functionality. The features are described below. `f32`, `f64`, `std`, and `si` are\nenabled by default. Features can be cherry-picked by using the `--no-default-features` and\n`--features \"...\"` flags when compiling `uom` or specifying features in Cargo.toml:\n\n```toml\n[dependencies]\nuom = {\n    version = \"0.36.0\",\n    default-features = false,\n    features = [\n        \"autoconvert\", # automatic base unit conversion.\n        \"usize\", \"u8\", \"u16\", \"u32\", \"u64\", \"u128\", # Unsigned integer storage types.\n        \"isize\", \"i8\", \"i16\", \"i32\", \"i64\", \"i128\", # Signed integer storage types.\n        \"bigint\", \"biguint\", # Arbitrary width integer storage types.\n        \"rational\", \"rational32\", \"rational64\", \"bigrational\", # Integer ratio storage types.\n        \"complex32\", \"complex64\", # Complex floating point storage types.\n        \"f32\", \"f64\", # Floating point storage types.\n        \"si\", \"std\", # Built-in SI system and std library support.\n        \"serde\", # Serde support.\n    ]\n}\n```\n\n * `autoconvert` -- Feature to enable automatic conversion between base units in binary operators.\n   Disabling the feature only allows for quantities with the same base units to directly interact.\n   The feature exists to account for compiler limitations where zero-cost code is not generated for\n   non-floating point underlying storage types.\n * `usize`, `u8`, `u16`, `u32`, `u64`, `u128`, `isize`, `i8`, `i16`, `i32`, `i64`, `i128`, `bigint`,\n   `biguint`, `rational`, `rational32`, `rational64`, `bigrational`, `complex32`, `complex64`,\n   `f32`, `f64` -- Features to enable underlying storage types. At least one of these features must\n   be enabled. `f32` and `f64` are enabled by default. See the [Design](#design) section for\n   implications of choosing different underlying storage types.\n * `si` -- Feature to include the pre-built [International System of Units][si] (SI). Enabled by\n   default.\n * `std` -- Feature to compile with standard library support. Disabling this feature compiles `uom`\n   with `no_std`. Enabled by default.\n * `serde` -- Feature to enable support for serialization and deserialization of quantities with the\n   [Serde][serde] crate. Disabled by default. Replaces the deprecated `use_serde` feature, which will\n   be removed in a future `uom` release (v0.37.0 or later).\n\n[si]: https://jcgm.bipm.org/vim/en/1.16.html\n[serde]: https://serde.rs/\n\n## Design\nRather than working with [measurement units](https://jcgm.bipm.org/vim/en/1.9.html) (meter,\nkilometer, foot, mile, ...) `uom` works with [quantities](https://jcgm.bipm.org/vim/en/1.1.html)\n(length, mass, time, ...). This simplifies usage because units are only involved at interface\nboundaries: the rest of your code only needs to be concerned about the quantities involved. This\nalso makes operations on quantities (+, -, \\*, /, ...) have zero runtime cost over using the raw\nstorage type (e.g. `f32`).\n\n`uom` normalizes values to the [base unit](https://jcgm.bipm.org/vim/en/1.10.html) for the quantity.\nAlternative base units can be used by executing the macro defined for the system of quantities\n(`ISQ!` for the SI). `uom` supports `usize`, `u8`, `u16`, `u32`, `u64`, `u128`, `isize`, `i8`,\n`i16`, `i32`, `i64`, `i128`, `bigint`, `biguint`, `rational`, `rational32`, `rational64`,\n`bigrational`, `complex32`, `complex64`, `f32`, and `f64` as the underlying storage type.\n\nA consequence of normalizing values to the base unit is that some values may not be able to be\nrepresented or can't be precisely represented for floating point and rational underlying storage\ntypes. For example if the base unit of `length` is `meter` and the underlying storage type is `i32`\nthen values like `1 centimeter` or `1.1 meter` cannot be represented. `1 centimeter` is normalized\nto `0.01 meter` which can't be stored in an `i32`. `uom` only allows units to be used safely. Users\nof this library will still need to be aware of implementation details of the underlying storage type\nincluding limits and precision.\n\n## Contributing\nContributions are welcome from everyone. Submit a pull request, an issue, or just add comments to an\nexisting item. The [International Bureau of Weights and Measures][BIPM] is an international\nstandards organization that publishes the [SI Brochure][brochure]. This document defines the [SI]\nand can be used as a comprehensive reference for changes to `uom`. Conversion factors for non-SI\nunits can be found in NIST [Special Publication 811][nist811].\n\nUnless you explicitly state otherwise, any contribution intentionally submitted for inclusion in\nthe work by you, as defined in the Apache-2.0 license, shall be dual licensed as below, without any\nadditional terms or conditions.\n\n### License\nLicensed under either of\n\n * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or\n   \u003chttps://www.apache.org/licenses/LICENSE-2.0\u003e)\n * MIT license ([LICENSE-MIT](LICENSE-MIT) or \u003chttps://opensource.org/licenses/MIT\u003e)\n\nat your option.\n\n[BIPM]: https://www.bipm.org/en/about-us/\n[brochure]: https://www.bipm.org/en/publications/si-brochure/\n[si]: https://jcgm.bipm.org/vim/en/1.16.html\n[nist811]: https://www.nist.gov/pml/special-publication-811/nist-guide-si-appendix-b-conversion-factors/nist-guide-si-appendix-b9\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Filiekturtles%2Fuom","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Filiekturtles%2Fuom","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Filiekturtles%2Fuom/lists"}