zeroize 1.0.0

Securely clear secrets from memory with a simple trait built on stable Rust primitives which guarantee memory is zeroed using an operation will not be 'optimized away' by the compiler. Uses a portable pure Rust implementation that works everywhere, even WASM!
Documentation
//! `Zeroize` impl for the `BytesMut` type from the `bytes` crate

// TODO(tarcieri): upstream this?

use super::Zeroize;
use ::bytes::BytesMut;

impl Zeroize for BytesMut {
    fn zeroize(&mut self) {
        self.resize(self.capacity(), Default::default());
        self.as_mut().zeroize();
        self.clear();
        debug_assert!(self.iter().all(|b| *b == 0));
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn zeroize_bytes() {
        let mut data = BytesMut::from("data");
        data.zeroize();
        assert!(data.is_empty());

        let mut data = BytesMut::from("data");
        data.zeroize();
        assert!(data.is_empty());
    }
}