Stops returning an option in the internal searchable fields

This commit is contained in:
Tamo
2024-05-06 14:49:45 +02:00
parent 76bb6d565c
commit c22460045c
9 changed files with 120 additions and 90 deletions

View File

@ -0,0 +1,28 @@
use std::collections::HashMap;
use serde::{Deserialize, Serialize};
use crate::{FieldId, Weight};
#[derive(Debug, Default, Serialize, Deserialize)]
pub struct FieldidsWeightsMap {
map: HashMap<FieldId, Weight>,
}
impl FieldidsWeightsMap {
pub fn insert(&mut self, fid: FieldId, weight: Weight) -> Option<Weight> {
self.map.insert(fid, weight)
}
pub fn remove(&mut self, fid: FieldId) -> Option<Weight> {
self.map.remove(&fid)
}
pub fn weight(&self, fid: FieldId) -> Option<Weight> {
self.map.get(&fid).copied()
}
pub fn max_weight(&self) -> Option<Weight> {
self.map.values().copied().max()
}
}