Skip to content

Commit

Permalink
docs: add documentation and tests for Timeout::from_str
Browse files Browse the repository at this point in the history
  • Loading branch information
rnestler committed Dec 12, 2022
1 parent 86f40f1 commit b6c11dc
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/timeout.rs
Expand Up @@ -60,6 +60,17 @@ impl From<Timeout> for i32 {
impl FromStr for Timeout {
type Err = ParseIntError;

/// Parse a string to a `Timeout` value.
///
/// Takes either "default", "never" or a positive number and converts it to `Timeout`
/// # Example
/// ```
/// # use notify_rust::Timeout;
/// # use std::str::FromStr;
/// assert_eq!(Timeout::from_str("default").unwrap(), Timeout::Default);
/// assert_eq!(Timeout::from_str("never").unwrap(), Timeout::Never);
/// assert_eq!(Timeout::from_str("1000").unwrap(), Timeout::Milliseconds(1000));
/// ```
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"default" => Ok(Timeout::Default),
Expand Down

0 comments on commit b6c11dc

Please sign in to comment.