diff options
| author | Owen Jacobson <owen@grimoire.ca> | 2022-06-08 17:39:30 -0400 |
|---|---|---|
| committer | Owen Jacobson <owen@grimoire.ca> | 2022-06-08 17:39:30 -0400 |
| commit | ca1b3e0d3215d4e4c0c60c5ff6bf5c99597cae7e (patch) | |
| tree | c2b78240cbe1a54937aba800fa9ac28f06187197 /src/view.rs | |
| parent | 06664ab21b100e65eb4357e6bd24656f8f9d194a (diff) | |
Based on readability feedback, this is clearer.
Diffstat (limited to 'src/view.rs')
| -rw-r--r-- | src/view.rs | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/view.rs b/src/view.rs index ba15915..2062522 100644 --- a/src/view.rs +++ b/src/view.rs @@ -140,8 +140,10 @@ async fn index( None => data.0.choose(&mut thread_rng()), }; - let thing = thing.ok_or_else(|| error::ErrorNotFound("Not found"))?; - let (index, thing) = thing.to_owned(); + let (index, thing) = match thing { + Some(thing) => thing.to_owned(), + None => return Err(error::ErrorNotFound("Not found")), + }; let response = Suggestion { thing, req, index }; let response = response @@ -161,7 +163,10 @@ struct SlackMessage<'a> { async fn slack_troubleshoot(data: web::Data<Things>) -> error::Result<impl Responder> { let thing = data.0.choose(&mut thread_rng()); - let (_, thing) = thing.ok_or_else(|| error::ErrorNotFound("Not found"))?; + let (_, thing) = match thing { + Some(thing) => thing.to_owned(), + None => return Err(error::ErrorNotFound("Not found")), + }; let response = SlackMessage { response_type: "in_channel", |
