Skip to content

Commit

Permalink
add links to crates
Browse files Browse the repository at this point in the history
  • Loading branch information
Tehforsch committed Feb 25, 2024
1 parent 07a1f0d commit 011fbb5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Diman is a library for zero-cost compile time unit checking.

```rust
use diman::si::dimensions::{Length, Time, Velocity};
use diman::si::units::{seconds, meters, kilometers, hours};
use diman::si::units::{seconds, meters, kilometers, hours, hour};

fn get_velocity(x: Length<f64>, t: Time<f64>) -> Velocity<f64> {
x / t
Expand All @@ -14,9 +14,10 @@ let v1 = get_velocity(36.0 * kilometers, 1.0 * hours);
let v2 = get_velocity(10.0 * meters, 1.0 * seconds);

assert_eq!(v1, v2);
assert_eq!(format!("{} km/h", v1.value_in(kilometers / hour)), "36 km/h");
```

Let's try to add quantities with incompatible dimensions:
Diman prevents unit errors at compile time:
```rust
let time = 1.0 * seconds;
let length = 10.0 * meters;
Expand Down Expand Up @@ -268,7 +269,7 @@ The unit system generated with `rational-dimensions` supports a superset of feat
Still, this feature should be enabled only when necessary, since the compiler errors in case of dimension mismatches will be harder to read.

# `serde`
Serialization and deserialization of the units is provided via `serde` if the `serde` feature gate is enabled:
Serialization and deserialization of the units is provided via [`serde`](https://crates.io/crates/serde) if the `serde` feature gate is enabled:
```rust
#[derive(Serialize, Deserialize, Debug, PartialEq)]
struct Parameters {
Expand All @@ -291,7 +292,7 @@ assert_eq!(
```

# `rand`
Diman allows generating random quantities via `rand` if the `rand` feature gate is enabled:
Diman allows generating random quantities via [`rand`](https://crates.io/crates/rand) if the `rand` feature gate is enabled:
```rust

let mut rng = rand::thread_rng();
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@
//! Still, this feature should be enabled only when necessary, since the compiler errors in case of dimension mismatches will be harder to read.
//!
//! # `serde`
//! Serialization and deserialization of the units is provided via `serde` if the `serde` feature gate is enabled:
//! Serialization and deserialization of the units is provided via [`serde`](https://crates.io/crates/serde) if the `serde` feature gate is enabled:
//! ```ignore
//! # use diman::si::dimensions::{Length, Velocity};
//! # use diman::si::units::{meters, meters_per_second};
Expand All @@ -378,7 +378,7 @@
//! ```
//!
//! # `rand`
//! Diman allows generating random quantities via `rand` if the `rand` feature gate is enabled:
//! Diman allows generating random quantities via [`rand`](https://crates.io/crates/rand) if the `rand` feature gate is enabled:
//! ```ignore
//! # use rand::Rng;
//! # use diman::si::units::{meters, kilometers};
Expand Down

0 comments on commit 011fbb5

Please sign in to comment.