From d3317ac125f91ee7bacdda7ada649dd1719dc2c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Nerma?= Date: Fri, 8 Dec 2023 16:33:27 +0100 Subject: [PATCH] Use .gen() method on SmallRng instead of casting --- src/history/file_backed.rs | 4 ++-- src/history/sqlite_backed.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/history/file_backed.rs b/src/history/file_backed.rs index fac7874d..bc90e82a 100644 --- a/src/history/file_backed.rs +++ b/src/history/file_backed.rs @@ -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, @@ -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 diff --git a/src/history/sqlite_backed.rs b/src/history/sqlite_backed.rs index a04ca571..556404fe 100644 --- a/src/history/sqlite_backed.rs +++ b/src/history/sqlite_backed.rs @@ -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; @@ -60,7 +60,7 @@ fn deserialize_history_item(row: &rusqlite::Row) -> rusqlite::Result HistoryItemId { - HistoryItemId(self.rng.next_u64() as i64) + HistoryItemId(self.rng.gen()) } fn save(&mut self, entry: &HistoryItem) -> Result<()> {