Use rand::thread_rng to impl Default for Nonce.
This commit is contained in:
parent
a64a051276
commit
252dce1bad
|
@ -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"
|
||||
|
|
|
@ -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())
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue