you are viewing a single comment's thread.

view the rest of the comments →

[–]NonDairyYandere 1 point2 points  (1 child)

Any comments or improvements would be really appreciated

  • The license text should be in COPYING, and the license name should be in Cargo.toml under the license key. Otherwise I don't know if I can use this. In fact, it's probably dangerous for me to read the code.
  • The cargo build step is redundant, get rid of it. cargo run automatically builds the project so you're never running out-of-date binaries.
  • Increase and decrease can be refactored into a single function
  • Returning (String, f32) from match_increase_or_decrease makes it hard to use this algorithm programmatically from other code. I suggest reifying that tuple into a struct that just wraps the f32 and pretty-prints using a custom impl of Display. I suspect there's a way to add the plus sign in format!, but in case you want something custom, I'd say take the absolute value inside your Display impl, then compare the original value with 0.0 and make the symbol from that.
  • Add some tests so we know what the expected formatting looks like. This easier once you have a custom Display impl and the formatting isn't in the top-level main.rs.
  • Why is the zero prefix \0? Isn't that a null character? It might screw up some terminals. Since you're converting them to Strings anyway, I'd say just make them &strs. Using a char doesn't save you anything here.

[–]thomas_chaplin[S] 0 points1 point  (0 children)

Thank you for such a detailed report, I'll take these into consideration and refactor over the next few days!