~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

[PATCH v2] fix: If count 0 fail early

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

diff --git a/src/theme.rs b/src/theme.rs
index 5a57c24..f0e013a 100644
--- a/src/theme.rs
+++ b/src/theme.rs
@@ -48,7 +48,11 @@ impl ThemeClient {
            .await?;

        if let Some(cap) = self.count_re.captures(&page) {
            Ok(Some(cap[1].parse::<u64>().unwrap_or(1)))
            let count = cap[1].parse::<u64>().unwrap_or(1);
            match count {
                0 => Ok(None),
                _ => Ok(Some(count)),
            }
        } else {
            Ok(None)
        }
@@ -96,6 +100,7 @@ impl ThemeClient {
            Some(c) => c,
            None => return Ok(ComicEmbed::new().theme_fail()),
        };

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

        use rand::distributions::Distribution;
-- 
2.27.0
Reply to thread Export thread (mbox)