Use rand::thread_rng to impl Default for Nonce.

This commit is contained in:
Henry de Valence 2019-09-19 14:13:38 -07:00
parent b3e094bc40
commit cb28d40665
2 changed files with 8 additions and 0 deletions

View File

@ -7,6 +7,7 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
rand = "0.7"
byteorder = "1.3"
chrono = "0.4"
failure = "0.1"

View File

@ -17,3 +17,10 @@ pub struct Services(pub u64);
/// A nonce used in the networking layer to identify messages.
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub struct Nonce(pub u64);
impl Default for Nonce {
fn default() -> Self {
use rand::{thread_rng, Rng};
Self(thread_rng().gen())
}
}