{"id":16680479,"url":"https://github.com/paholg/dimensioned","last_synced_at":"2025-05-16T10:08:48.947Z","repository":{"id":23546445,"uuid":"26913539","full_name":"paholg/dimensioned","owner":"paholg","description":"Compile-time dimensional analysis for various unit systems using Rust's type system.","archived":false,"fork":false,"pushed_at":"2022-12-09T19:56:02.000Z","size":467,"stargazers_count":303,"open_issues_count":17,"forks_count":21,"subscribers_count":11,"default_branch":"main","last_synced_at":"2025-05-11T00:06:51.809Z","etag":null,"topics":["conversion","dimensional-analysis","dimensions","rust","type-safety","units"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/dimensioned","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/paholg.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-11-20T13:29:33.000Z","updated_at":"2025-04-29T16:21:17.000Z","dependencies_parsed_at":"2023-01-13T23:28:23.264Z","dependency_job_id":null,"html_url":"https://github.com/paholg/dimensioned","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paholg%2Fdimensioned","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paholg%2Fdimensioned/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paholg%2Fdimensioned/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paholg%2Fdimensioned/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/paholg","download_url":"https://codeload.github.com/paholg/dimensioned/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254509478,"owners_count":22082892,"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":["conversion","dimensional-analysis","dimensions","rust","type-safety","units"],"created_at":"2024-10-12T13:41:47.463Z","updated_at":"2025-05-16T10:08:43.916Z","avatar_url":"https://github.com/paholg.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![crates.io](https://img.shields.io/crates/v/dimensioned.svg)](https://crates.io/crates/dimensioned)\n[![Build Status](https://github.com/paholg/dimensioned/actions/workflows/check.yml/badge.svg)](https://github.com/paholg/dimensioned/actions/workflows/check.yml)\n\n[Documentation](https://docs.rs/dimensioned/)\n\nDimensioned\n=====\n\nA Rust library for compile-time dimensional analysis.\n\nIts goal is to provide zero cost unit safety while requiring minimal effort from the programmer.\n\n# Use\n\nDimensioned requires at least Rust version 1.23.0 (and is tested on this version), although some\nfeatures may require a newer version.\n\nIt does not depend on `std`; simple include without the default feature `std`. Doing so requires a\nnightly version of rustc.\n\nIf you are using Rust nightly, then you may enable the \"oibit\" feature of dimensioned. This will\nmake it work a bit better for wrapping non-primitives in units. The recommended way to use\ndimensioned is by wrapping only primitives in units, in which case this feature is not helpful.\n\n# Contributing\n\nContributions are welcome! There aren't super strict contributing guidelines, but I have a few\nrequests.\n\n* Note changes that you make in [CHANGELOG.md](CHANGELOG.md).\n* Add documentation and tests for anything that you add.\n* Try to keep lists alphabetized in files not addressed by rustfmt.\n* Don't hesitate to prod me if I haven't responded to you in a timely manner. I get\n  busy and forgetful, but I would like to repond to issues and PRs promptly.\n* Feel free to ask questions!\n\n# Examples\n\n[The Simulation Example](https://github.com/paholg/dimensioned-examples/blob/master/hard-spheres.md)\nprovides a simple physics simulation and covers how one can use dimensioned with it in a couple\ndifferent ways, and what the trade-offs are. If you're curious about what might be involved in\nadding dimensioned to one of your projects, or what it might look like in semi-real code, then that\nis the place for you.\n\n[The Conversion Example](https://github.com/paholg/dimensioned-examples/blob/master/src/conversion.md)\ncovers how one might implement conversions between unit systems.\n\nFinally, just to get the juices flowing, here's a simple example illustrating some of what\ndimensioned can do:\n\n```rust\nextern crate dimensioned as dim;\n\nuse dim::{si, cgs};\n\n// Calculates speed given a distance and time. Only works for SI units.\nfn speed(dist: si::Meter\u003cf64\u003e, time: si::Second\u003cf64\u003e) -\u003e si::MeterPerSecond\u003cf64\u003e {\n    dist / time\n}\n\nuse std::ops::Div;\nuse dim::dimensions::{Length, Time};\nuse dim::typenum::Quot;\n\n// Calculates speed as before, but now we can use *any* unit system.\nfn generic_speed\u003cL, T\u003e(dist: L, time: T) -\u003e Quot\u003cL, T\u003e\n    where L: Length + Div\u003cT\u003e, T: Time,\n{\n    dist / time\n}\n\nfn main() {\n    let si_x = 6.0 * si::M;\n    let si_t = 3.0 * si::S;\n    let si_v = 2.0 * si::M / si::S;\n\n    let si_v2 = speed(si_x, si_t);\n    assert_eq!(si_v, si_v2);\n\n    let cgs_x = 6.0 * cgs::M;\n    let cgs_t = 3.0 * cgs::S;\n    let cgs_v = 2.0 * cgs::M / cgs::S;\n\n    let cgs_v2 = generic_speed(cgs_x, cgs_t);\n    assert_eq!(cgs_v, cgs_v2);\n\n    let si_v3 = cgs_v2.into();\n    assert_eq!(si_v2, si_v3);\n}\n\n```\n\nThis example is also included as `examples/readme-example.rs`.\n\n# Unit Systems\n\nDimensioned aims to include unit systems for a large variety of uses. It also includes a\n`make_units!` macro to allow you to create any unit system you desire.\n\n# Error Messages\n\nProbably the biggest weakness of dimensioned are the error messages generated. The type\nsignatures coming from dimensioned tend to just look like a bunch of gobbly-guck. Someday, we may\nhave a better way to display them.\n\nFor now, my advice is that when you get an error message involving *dimensioned*, just go to the\nline number and hopefully the issue will be apparant from the code alone.\n\n# Friends of dimensioned\n\nIf there are any libraries that work particularly well with dimensioned, such as the vector3d\nlibrary used in part 3 of the simulation example, please let me know and they will be listed here.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaholg%2Fdimensioned","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpaholg%2Fdimensioned","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaholg%2Fdimensioned/lists"}