mirror of
https://github.com/librespot-org/librespot.git
synced 2025-03-09 00:17:28 +00:00
connect: use small_rng, derive Default
This commit is contained in:
parent
f57fdf951a
commit
f596b1cdd2
2 changed files with 5 additions and 11 deletions
connect
|
@ -12,7 +12,7 @@ edition = "2021"
|
|||
futures-util = "0.3"
|
||||
log = "0.4"
|
||||
protobuf = "3.5"
|
||||
rand = "0.8"
|
||||
rand = { version = "0.8", default-features = false, features = ["small_rng"] }
|
||||
serde_json = "1.0"
|
||||
thiserror = "2.0"
|
||||
tokio = { version = "1", features = ["macros", "parking_lot", "sync"] }
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
use rand::{Rng, SeedableRng};
|
||||
use rand::{rngs::SmallRng, Rng, SeedableRng};
|
||||
use std::{
|
||||
ops::{Deref, DerefMut},
|
||||
vec::IntoIter,
|
||||
};
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Clone, Default)]
|
||||
pub struct ShuffleVec<T> {
|
||||
vec: Vec<T>,
|
||||
indices: Option<Vec<usize>>,
|
||||
|
@ -45,12 +45,6 @@ impl<T> From<Vec<T>> for ShuffleVec<T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T> Default for ShuffleVec<T> {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> ShuffleVec<T> {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
|
@ -60,7 +54,7 @@ impl<T> ShuffleVec<T> {
|
|||
}
|
||||
|
||||
pub fn shuffle_with_seed(&mut self, seed: u64) {
|
||||
self.shuffle_with_rng(rand::rngs::StdRng::seed_from_u64(seed))
|
||||
self.shuffle_with_rng(SmallRng::seed_from_u64(seed))
|
||||
}
|
||||
|
||||
pub fn shuffle_with_rng(&mut self, mut rng: impl Rng) {
|
||||
|
@ -97,7 +91,7 @@ impl<T> ShuffleVec<T> {
|
|||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use crate::shuffle_vec::ShuffleVec;
|
||||
use super::*;
|
||||
use rand::Rng;
|
||||
|
||||
#[test]
|
||||
|
|
Loading…
Reference in a new issue