From c9e749f811b16f7ec352d2aa8773105af046fad8 Mon Sep 17 00:00:00 2001 From: lukeflo Date: Mon, 7 Oct 2024 16:15:49 +0200 Subject: add func for entry items, UI enhancement - add functions to get url/doi and filepath - get values for entry info from structs not by calling funcs again --- src/backend/search.rs | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'src/backend/search.rs') diff --git a/src/backend/search.rs b/src/backend/search.rs index 7319acc..2c11355 100644 --- a/src/backend/search.rs +++ b/src/backend/search.rs @@ -26,7 +26,7 @@ impl Default for BibiSearch { impl BibiSearch { // Stringify inner Vec by joining/concat fn convert_to_string(inner_vec: &Vec) -> String { - inner_vec.join(" ") + inner_vec[0..6].join(" ") } // Return a filtered entry list @@ -89,3 +89,30 @@ impl BibiSearch { filtered_list } } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_vector_join() { + let bibvec = vec![ + "Author".to_string(), + "Title".to_string(), + "1999".to_string(), + "article".to_string(), + "hello, bye".to_string(), + "author_1999".to_string(), + "An abstract with multiple sentences. Sometimes thats necessary".to_string(), + "www.bibiman.org".to_string(), + "/home/file/path.pdf".to_string(), + ]; + + let joined_vec = BibiSearch::convert_to_string(&bibvec); + + assert_eq!( + joined_vec, + "Author Title 1999 article hello, bye author_1999" + ) + } +} -- cgit v1.2.3