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
Implement FromStr for Timeout #169
Conversation
really nice, I love this! Thank you |
Useful when wanting to pass it as a command line argument to an application.
can you please allow me to push onto your branch? |
284e3df
to
b6c11dc
Compare
match s { | ||
"default" => Ok(Timeout::Default), | ||
"never" => Ok(Timeout::Never), | ||
milliseconds => Ok(Timeout::Milliseconds(u32::from_str(milliseconds)?)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This also allows to create Timeout::Milliseconds(0)
by passing "0"
, but I don't think it is worth to handle the special case, since it is also possible to just construct a Timeout::Milliseconds(0)
directly.
b6c11dc
to
208d55d
Compare
This included the `FromStr` for `Timeout` implementation (hoodie/notify-rust#169) so we can get rid of our custom implementation.
This included the `FromStr` for `Timeout` implementation (hoodie/notify-rust#169) so we can get rid of our custom implementation.
Useful when wanting to pass it as a command line argument to an application.
I recently needed to pass the notification timeout on the command line. I ended up implementing a custom function, but thought maybe it would be a nice addition:
See https://github.com/rnestler/reboot-arch-btw/pull/106/files#diff-42cb6807ad74b3e201c5a7ca98b911c5fa08380e942be6e4ac5807f8377f87fcR18-R25
If you think this is a good thing, then I'd of course also add tests and whatever else you think is necessary.