Commit graph

612 commits

Author SHA1 Message Date
Alex Alemi
f0e6e058d5 Another cargo fmt 2020-04-22 22:13:18 -04:00
Alex Alemi
b72bc0f80f cargo fix --edition-idioms 2020-04-22 22:06:35 -04:00
Alex Alemi
a8d8a4d7f7 fmt 2020-04-22 22:04:30 -04:00
Alex Alemi
3a2aa4c44d Manually remove trailing semicolons; Update edition 2020-04-22 22:04:18 -04:00
Alex Alemi
0d10f2d0e6 cargo fix --edition 2020-04-22 21:59:34 -04:00
Alex Alemi
1195f7832e try! -> ? everywhere 2020-04-22 21:56:38 -04:00
Alex Alemi
7197d91e47 After merging PR#40 2020-04-22 21:43:47 -04:00
Tiffany Bennett
03bfc41047
Merge pull request #53 from bhipple/fix/lockfile
Include Cargo.lock in src
2020-02-15 23:16:43 -08:00
Benjamin Hipple
9ec790dcec Include Cargo.lock in src
Since this is producing a binary that users and distributions want to install,
we should include a Cargo.lock for a deterministic build.

https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
https://reproducible-builds.org/
2020-02-16 01:17:03 -05:00
Tiffany Bennett
eb3397b744
Merge pull request #51 from DeeUnderscore/offset-dates
Make dates with numerical offsets get parsed correctly
2019-12-31 16:53:42 -05:00
D Anzorge
603910759e Modify date offset parsing tests
Change one test to reflect current behavior and add one test with
different offsets.
2019-12-31 19:58:52 +01:00
D Anzorge
6544e69202 Make dates with offsets parse correctly 2019-12-31 19:13:55 +01:00
Tiffany Bennett
d37bedc365
Merge pull request #47 from delan/delan/prolactin-definition
add prolactin’s biological activity “density” (µg/mIU)
2019-11-28 15:49:15 -08:00
Tiffany Bennett
d6fa991921
Merge branch 'master' into delan/prolactin-definition 2019-11-28 14:55:47 -08:00
Tiffany Bennett
d2fd44758d
Merge pull request #46 from delan/delan/steroid-hormone-definitions
add some steroid hormones to definitions.units
2019-11-28 14:22:59 -08:00
Delan Azabani
5675b1841e add prolactin’s biological activity “density” (µg/mIU)
This commit defines international units (IU) of biological activity,
as well as the biological activity “density” of the current reference
preparation of prolactin, to make it easier to convert prolactin
levels between ng/mL (as preferred in the US) and mIU/L (as preferred
in Australia).

I can’t find a formal term for the relationship between biological
activity and mass in reference preparations, so I’ve chosen “density”
by analogy with linear_density, area_density, etc. For example:

> 256 mIU/L * biological_activity_density of prolactin -> ng/mL
4096/335, approx. 12.22686 nanogram / milliliter (density)
2019-11-29 00:31:21 +11:00
Delan Azabani
0fd2c9d9ef add some steroid hormones to definitions.units
This commit defines some of the more important sex hormones and their
precursors, to make it easier to convert their levels between density
(as preferred in the US) and molar_concentration (as preferred in
Australia) without remembering any formulas. For example:

> 1212 pmol/L * molar_mass of oestradiol -> pg/mL
approx. 330.1334 picogram / milliliter (density)
> 5.9 nmol/L * molar_mass of progesterone -> ng/mL
approx. 1.855361 nanogram / milliliter (density)
> 0.5 nmol/L * molar_mass of testosterone -> ng/dL
approx. 14.42150 nanogram / deciliter (density)
2019-11-28 19:30:16 +11:00
Tiffany Bennett
70e309ce48
Update readme
Add a couple new badges, and update the web interface section
2019-10-30 20:59:27 -07:00
Tiffany Bennett
87495995e1
Merge pull request #43 from tiffany352/unicode-minus-sign
Parse U+2212 as minus sign (Fixes #33)
2019-10-30 20:39:21 -07:00
Tiffany Bennett
95713ba1b8 Parse U+2212 as minus sign (Fixes #33) 2019-10-30 20:26:01 -07:00
Tiffany Bennett
1af86eeaf8
Merge pull request #42 from tiffany352/use-reqwest
Replace hyper with reqwest
2019-10-30 20:18:40 -07:00
Tiffany Bennett
9029d8478e Replace hyper with reqwest 2019-10-30 19:49:32 -07:00
Tiffany Bennett
73d2b92a07
Merge pull request #41 from Aaron1011/fix/into-iter
Use `slice::iter` instead of `into_iter` to avoid future breakage
2019-10-30 13:14:32 -07:00
Aaron Hill
58e2bab9aa
Use slice::iter instead of into_iter to avoid future breakage
`an_array.into_iter()` currently just works because of the autoref
feature, which then calls `<[T] as IntoIterator>::into_iter`. But
in the future, arrays will implement `IntoIterator`, too. In order
to avoid problems in the future, the call is replaced by `iter()`
which is shorter and more explicit.
2019-10-30 15:57:35 -04:00
Tiffany Bennett
35bea0fe19 Remove unnecessary mut 2019-10-19 20:31:42 -07:00
Colin Benner
78331c36a8 Add parse_radix to handle near-identical cases
In `parse_term`, remove some code duplication by moving code common to
parsing hexadecimal, octal and binary numbers into its own
function.
2019-10-19 20:30:06 -07:00
Colin Benner
b035f08d49 Move Name, Resolver out of load::load 2019-10-19 20:28:00 -07:00
Colin Benner
bf46daa227 Simplify parse_term, eliminate is_func
Try to parse a function, or attribute, then match the result.  This
eliminates the two-step approach: check whether we have a function, then
parse as a function.
2019-10-19 20:28:00 -07:00
Colin Benner
8bcd12252a Rename is_attr to attr_from_name
A function returning an `Option` should not have a name beginning with
`is_`.
2019-10-19 20:28:00 -07:00
Colin Benner
124a41773a Move common subexpression out of match 2019-10-19 20:28:00 -07:00
Colin Benner
a7c746f48a Simplify match statement using try!
This is simpler than manually handling an error in each component of the
triple we match on.  In addition, we get to drop a bunch of `Ok`s.
2019-10-19 20:28:00 -07:00
Colin Benner
f805f5d180 Represent function using an enum
We only support a limited set of function, so we may as well put them in an
enum instead of passing around strings.  This allows us to simplify match
statements, eliminating the case of unsupported functions.
2019-10-19 20:28:00 -07:00
Colin Benner
1ce838983d Simplify some matches 2019-10-19 20:28:00 -07:00
Colin Benner
31897c48c1 Derive Default for NumberParts
No need to write this out explicitly.
2019-10-19 20:27:59 -07:00
Colin Benner
9c5818b2f2 Address more clippy carnings 2019-10-19 20:27:59 -07:00
Colin Benner
1e87d5a54f Get content from Name with one method
Get the content of whatever variant by calling `Name::name()`.
2019-10-19 20:27:59 -07:00
Colin Benner
9c74a38b4d Simplify Resolver::lookup
Move duplicate code into a closure.  Simplify inner using `.any()`.
Eliminate conditionals using logical operators.
2019-10-19 20:27:59 -07:00
Colin Benner
0b289c8966 Be more explicit in Num::to_rational
Rather than checking whether `x == ai`, we simply check whether their
difference, of which we want to take the reciprocal in the next step, is
zero.
2019-10-19 20:27:59 -07:00
Colin Benner
e68e4f6167 Use unreachable!() instead of panic!()
This seems to capture the intended meaning more clearly.
2019-10-19 20:27:59 -07:00
Colin Benner
5a0189ff77 Use the dirs crate to find the config dir 2019-10-19 20:27:59 -07:00
Colin Benner
62aec5a8a0 Handle division by zero with a macro
Eliminate repetitive code by using a simple macro all over
`substance.rs`.
2019-10-19 20:27:59 -07:00
Colin Benner
02f13cc7cb Merge if statement with surrounding else block 2019-10-19 20:27:59 -07:00
Colin Benner
0e65b19e56 Simplify Context::describe_unit
Move duplicate code into a closure.
2019-10-19 20:27:59 -07:00
Colin Benner
612ca08306 Use is_empty
Check whether a collections is empty by using the `.is_empty` method
instead of comparing `.len()` to 0.
2019-10-19 20:27:59 -07:00
Colin Benner
72864485b7 Simplify Context::{lookup, canonicalize} 2019-10-19 20:27:59 -07:00
Colin Benner
8247a2415c Fix lots of clippy warnings 2019-10-19 20:27:59 -07:00
Colin Benner
da9313f6fe Simplify match in text_query::is_func 2019-10-19 20:25:56 -07:00
Colin Benner
b042663807 Eliminate temperature! in eval::eval
Like the last, commit, replace the macro calls by putting the macro
arguments into variables and putting the macro body after that.

As we need the exact same match statement in both cases, it is
implemented as a method on `Degree`.
2019-10-19 20:25:56 -07:00
Colin Benner
249c9941af Eliminate macro in eval::eval_outer
We can get rid of `temperature!` if we just put the macro arguments into
variables and put the macro body below that.
2019-10-19 20:25:56 -07:00
Colin Benner
232f35c108 Use Display for Degree in token::describe 2019-10-19 20:25:56 -07:00