Skip to content

Commit

Permalink
update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
lucalewin committed Apr 25, 2023
1 parent c215b49 commit af48997
Showing 1 changed file with 10 additions and 21 deletions.
31 changes: 10 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,20 @@

Adds quantities and units to rust to allow unit safe computation

**Note**: this crate uses an unstable feature which requires you to add `#![feature(generic_const_exprs)]` and use the nightly compiler

## Define new quantity

### Base Quantity
currently only three dimensions are supported: Time, Length, Mass

```rust
quantity! {
name: Time,
base_unit: Second,
units: {
Second: 1e+0,
Millisecond: 1e-3,
}
}
```
use measurement::{Quantity, Dimension};

### Derived Quantity
pub type Time = Quantity<Dimension<1 /* time */, 0 /* length */, 0 /* mass */>>;
pub type Length = Quantity<Dimension<0, 1, 0>>;
pub type Mass = Quantity<Dimension<0, 0, 1>>;

pub type Velocity = Quantity<Dimension<-1, 1, 0>>;
pub type Acceleration = Quantity<Dimension<-2, 1, 0>>;

```rust
quantity! {
name: Velocity,
base_unit: MeterPerSecond,
units: {
MeterPerSecond: 1,
KilometerPerHour: 3.6,
},
derive: Length / Time,
}
```

0 comments on commit af48997

Please sign in to comment.