mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-02 01:25:27 +00:00
implement Default trait
This commit is contained in:
parent
9e86e9b29f
commit
9072b4dd21
1 changed files with 8 additions and 2 deletions
|
|
@ -9,6 +9,12 @@ pub struct Memory {
|
||||||
index: RefCell<HashMap<String, i64>>,
|
index: RefCell<HashMap<String, i64>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for Memory {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::new()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Memory {
|
impl Memory {
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
|
|
@ -56,7 +62,7 @@ impl Memory {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get recent requests vector sorted DESC by `ID`
|
/// Get recent requests vector sorted by `ID` DESC
|
||||||
pub fn recent(&self, limit: usize) -> Vec<String> {
|
pub fn recent(&self, limit: usize) -> Vec<String> {
|
||||||
let mut recent: Vec<String> = Vec::new();
|
let mut recent: Vec<String> = Vec::new();
|
||||||
for (request, _) in self
|
for (request, _) in self
|
||||||
|
|
@ -71,7 +77,7 @@ impl Memory {
|
||||||
recent
|
recent
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get total records in memory pool
|
/// Get records total
|
||||||
pub fn total(&self) -> usize {
|
pub fn total(&self) -> usize {
|
||||||
self.index.borrow().len()
|
self.index.borrow().len()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue