Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/deebloo/degrees
Easily handle temperature values in rust
https://github.com/deebloo/degrees
Last synced: 3 months ago
JSON representation
Easily handle temperature values in rust
- Host: GitHub
- URL: https://github.com/deebloo/degrees
- Owner: deebloo
- Created: 2023-09-17T12:42:51.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-05-05T10:43:05.000Z (8 months ago)
- Last Synced: 2024-10-05T13:07:42.756Z (3 months ago)
- Language: Rust
- Size: 27.3 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# degrees
Easily handle temperature values in rust.
The goal is to work with temps without needing to think about about units at all. A `Temp` is itself a value. The units are just for display back to the user.
You can compare and combine temps safely without manually converting to and from different units.
For example you can subtract 10degC from 86degF. The crate will handle the conversions internally and give you a result in the initial unit.
```rust
use degrees:Temp;let value = Temp::F(86.) - Temp::C(10.); // Temp::F(36.0)
```This also means you can safely compare temperatures in two different units
```rust
use degrees:Temp;let value = Temp::F(86.) == Temp::C(30.); // true
```Temps can be safely serialized and deserialized using serde when the `serde` feature is enabled.
```toml
[dependencies]
degrees = { version = "0.6.0", features = ["serde"] }
```