-
-
Notifications
You must be signed in to change notification settings - Fork 28
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
Some feedback #4
Comments
Oh, another suggestion: trait bounds on a struct definition can be, and usually are, un-ergonomic. David Tolnay, creator of serde, explains why. Take a look at std::collections::HashMap for an alternative. Hashmap doesn't impose bounds on its generic types in the struct definition. Instead the bounds are expressed on on an impl block. If |
Hi, Thanks for your feedback, your feedbacks are really cool and helpful to improve the project. Feel free to make a PR for your ideas! The cost is |
Hey there, very cool library. I was looking it over and noticed a few miscellaneous things that might improve it. In no particular order:
There are a couple instances of sentinel values in the api.
Duration::ZERO
indicates infinite ttl. This isn't what I would expect. Consider usingDuration::MAX
instead. (should make implementation simpler too)Coster
kicks in. This makes 0 a special value despite being a perfectly valid cost setting. Consider taking either anOption
cost in setter methods, or using a separate setter method that doesn't take a cost parameter, and usesCoster
to assign one.It's advisable to make invalid states unrepresentable. Costs are expressed as
i64
, notu64
. This struck me as odd. Are negative costs valid?This call to tokio select has only one future, which doesn't make sense considering what select does (it races multiple futures).
Cargo clippy is a really handy tool for improving code. Among other things, it helps catch errors and keeps code idiomatic. I do recommend trying it out on this repo as can give really useful suggestions and teach you about rust idioms. It currently reports 49 suggestions for this codebase.
This last one might just be personal preference. Macros are immensely useful, but do have costs, like confusing rustfmt or sometimes confusing people trying to understand the code. That said, I see couple instances where use of custom macros can be reduced. This for example could be replaced with:
The consistent and idiomatic formatting is much appreciated by the way. Make it a lot easier to dive into the code.
Again I think this library is super cool and nicely written. If you'd like me to address any or all of these points via pr please let me know.
The text was updated successfully, but these errors were encountered: