-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
modify shopping list printout to include ( N x stacks + remainder) when ingredient_count > 250 #1
Comments
Hi, it's a great idea and you almost have it working. The problem is that the ingredient count at that stage is a decimal type (from https://github.com/rust-num/num-rational) because that's what's used for the calculation internally, so it needs to be converted to an integer first. Here's a commit with a fix 0bb2d6b, and a type annotation on the hashmap to make it clear what it contains. If you want to create a PR so that you get credited I'll happily merge it! |
Thanks Tobias! You did the real work to add the feature, so I don't have any need for any credit. I'm just happy you shared the tool (and that not everyone is using it, so I can make a little 💰 periodically 😃 ). |
Ok! Added in 35b6e0c. |
Hi!
I can program in several languages, but Rust isn't one of them. I'm trying to modify the shopping list printout so that instead of
output like this:
I instead get output something like this:
In other words, make it report the number of stacks + remainder in the case when the buy order is larger than the stack size. I don't care if it says "N stacks + ###" or "Nx250 + ###" or something else, just that it does the math for me and makes it clear how many full stacks plus partial amount is required.
I made a clumsy attempt to do this myself by adding the following to your area containing constants:
and then as a first attempt I changed the recipe-printing code to:
Yes, it's an ugly way to do that (based on a couple hours of research I'm guessing using fmt!() to pre-format each line and then
output it would be better), but as I said, this is my first time trying to modify Rust code. I'm trying to get the basics working before making it clean code.
I'm running into an issue because of Rust's strong type system, though. I can't compare
ingredient_count
toITEM_STACK_SIZE
, I'm getting a mismatched types error:Any suggestions on how to pacify the type system?
Thanks!
solstice.1847
The text was updated successfully, but these errors were encountered: