Lines
73.91 %
Functions
35.71 %
Branches
100 %
use crate::types::{AccountSuggestion, TagSuggestion};
pub trait Suggestion: Clone + serde::de::DeserializeOwned + 'static {
fn display_text(&self) -> &str;
fn matches(&self, query: &str) -> bool;
fn get_id(&self) -> &str;
}
impl Suggestion for AccountSuggestion {
fn display_text(&self) -> &str {
&self.name
fn matches(&self, query: &str) -> bool {
self.name.to_lowercase().contains(&query.to_lowercase())
fn get_id(&self) -> &str {
&self.id
impl Suggestion for TagSuggestion {
let q = query.to_lowercase();
self.name.to_lowercase().contains(&q)
|| self
.value
.as_ref()
.is_some_and(|v| v.to_lowercase().contains(&q))
#[cfg(test)]
#[path = "suggestion_tests.rs"]
mod tests;