Skip to content

Commit

Permalink
Use .gen() method on SmallRng instead of casting
Browse files Browse the repository at this point in the history
  • Loading branch information
ClementNerma committed Dec 8, 2023
1 parent a61720d commit d3317ac
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/history/file_backed.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use indexmap::IndexMap;
use rand::{rngs::SmallRng, RngCore, SeedableRng};
use rand::{rngs::SmallRng, Rng, SeedableRng};

use super::{
base::CommandLineSearch, History, HistoryItem, HistoryItemId, SearchDirection, SearchQuery,
Expand Down Expand Up @@ -79,7 +79,7 @@ fn decode_entry(s: &str, counter: &mut i64) -> (HistoryItemId, String) {

impl History for FileBackedHistory {
fn generate_id(&mut self) -> HistoryItemId {
HistoryItemId(self.rng.next_u64() as i64)
HistoryItemId(self.rng.gen())
}

/// only saves a value if it's different than the last value
Expand Down
4 changes: 2 additions & 2 deletions src/history/sqlite_backed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::{
Result,
};
use chrono::{TimeZone, Utc};
use rand::{rngs::SmallRng, RngCore, SeedableRng};
use rand::{rngs::SmallRng, Rng, SeedableRng};
use rusqlite::{named_params, params, Connection, ToSql};
use std::{path::PathBuf, time::Duration};
const SQLITE_APPLICATION_ID: i32 = 1151497937;
Expand Down Expand Up @@ -60,7 +60,7 @@ fn deserialize_history_item(row: &rusqlite::Row) -> rusqlite::Result<HistoryItem

impl History for SqliteBackedHistory {
fn generate_id(&mut self) -> HistoryItemId {
HistoryItemId(self.rng.next_u64() as i64)
HistoryItemId(self.rng.gen())
}

fn save(&mut self, entry: &HistoryItem) -> Result<()> {
Expand Down

0 comments on commit d3317ac

Please sign in to comment.