Trangar / periodic_table

Library that provides a list of elements in the periodic table
3 stars 1 forks source link

Improve generator #1

Closed VictorKoenders closed 5 years ago

VictorKoenders commented 6 years ago
VictorKoenders commented 6 years ago

09:13:09 < Xion_> https://github.com/Trangar/periodic_table/blob/master/src/main.rs#L89 -- You could wrap the Vec in a newtype and implement Display/Debug on it, it'd give you access to .debug_struct which is nicer than manual formating of struct decls 09:14:05 < Trangar> Is debugstruct guaranteed to be compileable code? 09:14:20 < Xion> I think so? 09:15:39 < Xion> The other obvious thing you could do is introduce more types rather than using strings everywhere 09:15:43 < Xion> E.g. for atomic mass 09:15:59 < Trangar> The obvious thing would be to just parse the CSV directly to an object that implements Deserialize 09:16:12 < Trangar> And then implement Debug for that that generates the proper code 09:16:21 < Xion> +1 that's a good idea 09:16:42 < Xion> It could even be the Element type :D 09:16:51 < Trangar> CsvElement or something

Xion commented 6 years ago

‹Xion›  You probably also want to add docs on every field :) E.g. melting/boilingPoint need a reference pressure ‹Xion›  (and probably an enum rather than Option, because there are three states: Unknown, Known(u32), NotApplicable in case of helium)

VictorKoenders commented 5 years ago

(Mostly) closed in #4, #5 and #6 (thanks @noirotm!)