diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-05-24 14:30:18 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-05-24 14:30:18 +0800 |
| commit | cd9c071ad96629acd94f2708e807f55fadd91e63 (patch) | |
| tree | a9265186b0178506acfe3860c41b727fb0828aeb /src | |
| parent | 364981f212caaeb7ca4908122b65562baee295ac (diff) | |
Extract entries containing "IMPORTANT" (case-insensitive) in title or
content into a separate field, serialized as "IMPORTANT".
Diffstat (limited to 'src')
| -rw-r--r-- | src/mem_mgr.rs | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/src/mem_mgr.rs b/src/mem_mgr.rs index c6e442e..0709866 100644 --- a/src/mem_mgr.rs +++ b/src/mem_mgr.rs @@ -91,6 +91,8 @@ pub fn phantom_render_result_forgotten(_p: ResultForgotten) {} #[derive(Serialize, Groupped)] pub struct ResultDumpAll { + #[serde(rename = "IMPORTANT")] + pub important: Vec<ImportantEntry>, pub entries: Vec<DumpEntry>, } @@ -100,6 +102,12 @@ pub struct DumpEntry { pub content: String, } +#[derive(Serialize)] +pub struct ImportantEntry { + pub title: String, + pub reason: String, +} + #[renderer] pub fn phantom_render_result_dumpall(_p: ResultDumpAll) {} @@ -248,7 +256,30 @@ fn dumpall(constants: &Constants, about: String) -> ResultDumpAll { } } } - ResultDumpAll { entries } + + // Scan for IMPORTANT entries + let important: Vec<ImportantEntry> = entries + .iter() + .filter_map(|entry| { + let title_upper = entry.title.to_uppercase(); + let content_upper = entry.content.to_uppercase(); + if title_upper.contains("IMPORTANT") { + Some(ImportantEntry { + title: entry.title.clone(), + reason: "title contains IMPORTANT".to_string(), + }) + } else if content_upper.contains("IMPORTANT") { + Some(ImportantEntry { + title: entry.title.clone(), + reason: "content contains IMPORTANT".to_string(), + }) + } else { + None + } + }) + .collect(); + + ResultDumpAll { entries, important } } fn item_path(constants: &Constants, title: &String) -> PathBuf { |
