drodil / rustybeer

CLI tool to calculate beer brewing values for different things
https://drodil.github.io/rustybeer/
Other
12 stars 7 forks source link

beer_styles: store data as JSON #75

Closed tommilligan closed 4 years ago

tommilligan commented 4 years ago

Closes #43

Implements the beer_styles data as a JSON data file, rather than native rust structs.

This data is inlined at compile time using the include_str! macro, and deserialised the first time BEER_STYLES is dereferenced (using once_cell).

The additional refactoring of commands/beer_style.rs is due to the fact that BeerStyle is no longer Copy as it contains a String. The way results are calculated now results in less data copying overall, so I think it's a win still.

is it possible to do somehow so that the users of the library have the same data available?

Yep, external users can still use the data as before by use rustybeer::utils::beer_styles::BEER_STYLES;. The type has changed to Vec<BeerStyle> though. If you'd already published 0.1.0 that would make this a breaking change.

drodil commented 4 years ago

Thanks for the contribution! We haven't pushed this package yet as it's missing quite a lot of things before being useful for anybody. I will check the changes when I get back on computer

tommilligan commented 4 years ago

Clippy appears to be failing with some existing master issues

drodil commented 4 years ago

@all-contributors please add @tommilligan for Code

allcontributors[bot] commented 4 years ago

@drodil

I've put up a pull request to add @tommilligan! :tada: