~erk/inbox

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
1

[PATCH] fix: If count 0 fail early

Details
Message ID
<20200701235314.134634-1-flat@esoteric.moe>
DKIM signature
missing
Download raw message
Patch: +2 -1
Signed-off-by: Ken Swenson <flat@esoteric.moe>
---
 src/theme.rs | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/theme.rs b/src/theme.rs
index 5a57c24..db7d268 100644
--- a/src/theme.rs
+++ b/src/theme.rs
@@ -93,9 +93,10 @@ impl ThemeClient {

    pub async fn get_theme(&self, theme: &str) -> GarfieldResult<ComicEmbed> {
        let count = match self.get_count(theme).await? {
            Some(c) => c,
            Some(c) => match c { 0 => return Ok(ComicEmbed::new().theme_fail()), _=> c,},
            None => return Ok(ComicEmbed::new().theme_fail()),
        };

        let range = rand::distributions::Uniform::new(0, count);

        use rand::distributions::Distribution;
-- 
2.27.0
Details
Message ID
<865zb6rdmu.wl-valdemar@erk.io>
In-Reply-To
<20200701235314.134634-1-flat@esoteric.moe> (view parent)
DKIM signature
missing
Download raw message
I think it would be cleaner to make get_count return None instead of
doing it inside of the match branch.
Reply to thread Export thread (mbox)