Hacker News new | ask | show | jobs
by pitterpatter 4685 days ago
>but I doubt Rust has something like this.

Oh, but it does! There's the cond! macro:

    let computed_key = cond!(
        (key.len() > self.block_size) { self.zero_pad(self.hash(key).digest) }
        (key.len() < self.block_size) { self.zero_pad(key) }
        _                             { key }
    );