aoc_leaderbot_slack_lib 3.0.0

Slack-specific support library for aoc_leaderbot, an Advent of Code leaderboard-watching bot
use itertools::repeat_n;

pub trait SlackWebhookReporterStringExt {
    fn right_pad(self, width: usize, with: char) -> String;
}

impl<S> SlackWebhookReporterStringExt for S
where
    S: Into<String>,
{
    fn right_pad(self, width: usize, with: char) -> String {
        let mut s = self.into();

        match width.saturating_sub(s.chars().count()) {
            0 => s,
            missing => {
                s.extend(repeat_n(with, missing));
                s
            },
        }
    }
}