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 committed by Deirdre Connolly
parent a64a051276
commit 252dce1bad
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 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
rand = "0.7"
byteorder = "1.3" byteorder = "1.3"
chrono = "0.4" chrono = "0.4"
failure = "0.1" failure = "0.1"

View File

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