Added units of frequency
This commit is contained in:
parent
bba46e3ab4
commit
802ad3d88f
@ -84,6 +84,7 @@ round(sqrt(2)^4)! liters
|
||||
- Energy
|
||||
- Power
|
||||
- Pressure
|
||||
- Frequency
|
||||
- Speed
|
||||
- Temperature
|
||||
|
||||
@ -179,7 +180,6 @@ Nice list of units: https://support.google.com/websearch/answer/3284611
|
||||
- Angles
|
||||
- Electric current, capacitance, charge, conductance, volts
|
||||
- Flow rate
|
||||
- Frequency
|
||||
|
||||
### Cross-compiling
|
||||
1. [Install Docker](https://docs.docker.com/get-docker/)
|
||||
|
||||
@ -306,6 +306,14 @@ pub fn lex(input: &str, allow_trailing_operators: bool, default_degree: Unit) ->
|
||||
"psi" => tokens.push(Token::Unit(PoundsPerSquareInch)),
|
||||
"torr" | "torrs" => tokens.push(Token::Unit(Torr)),
|
||||
|
||||
"hz" | "hertz" => tokens.push(Token::Unit(Hertz)),
|
||||
"khz" | "kilohertz" => tokens.push(Token::Unit(Kilohertz)),
|
||||
"mhz" | "megahertz" => tokens.push(Token::Unit(Megahertz)),
|
||||
"ghz" | "gigahertz" => tokens.push(Token::Unit(Gigahertz)),
|
||||
"thz" | "terahertz" => tokens.push(Token::Unit(Terahertz)),
|
||||
"phz" | "petahertz" => tokens.push(Token::Unit(Petahertz)),
|
||||
"rpm" | "r/min" | "rev/min" => tokens.push(Token::Unit(RevolutionsPerMinute)),
|
||||
|
||||
"kph" | "kmh" => tokens.push(Token::Unit(KilometersPerHour)),
|
||||
"mps" => tokens.push(Token::Unit(MetersPerSecond)),
|
||||
"mph" => tokens.push(Token::Unit(MilesPerHour)),
|
||||
|
||||
10
src/units.rs
10
src/units.rs
@ -25,6 +25,8 @@ pub enum UnitType {
|
||||
Power,
|
||||
/// A unit of pressure, for example `Bar`
|
||||
Pressure,
|
||||
/// A unit of frequency, for example `Hertz`
|
||||
Frequency,
|
||||
/// A unit of x, for example `KilometersPerHour`
|
||||
Speed,
|
||||
/// A unit of temperature, for example `Kelvin`
|
||||
@ -216,6 +218,14 @@ create_units!(
|
||||
PoundsPerSquareInch: (Pressure, d128!(6894.757293168361)), // inexact
|
||||
Torr: (Pressure, d128!(162.12)),
|
||||
|
||||
Hertz: (Frequency, d128!(1)),
|
||||
Kilohertz: (Frequency, d128!(1000)),
|
||||
Megahertz: (Frequency, d128!(1000000)),
|
||||
Gigahertz: (Frequency, d128!(1000000000)),
|
||||
Terahertz: (Frequency, d128!(1000000000000)),
|
||||
Petahertz: (Frequency, d128!(1000000000000000)),
|
||||
RevolutionsPerMinute: (Frequency, d128!(60)),
|
||||
|
||||
KilometersPerHour: (Speed, d128!(1)),
|
||||
MetersPerSecond: (Speed, d128!(3.6)),
|
||||
MilesPerHour: (Speed, d128!(1.609344)),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user