First one-shot pass
This commit is contained in:
20
src/engine/filter.rs
Normal file
20
src/engine/filter.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
pub struct CharFilter {
|
||||
pub allowed: Vec<char>,
|
||||
}
|
||||
|
||||
impl CharFilter {
|
||||
pub fn new(allowed: Vec<char>) -> Self {
|
||||
Self { allowed }
|
||||
}
|
||||
|
||||
pub fn is_allowed(&self, ch: char) -> bool {
|
||||
self.allowed.contains(&ch) || ch == ' '
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn filter_text(&self, text: &str) -> String {
|
||||
text.chars()
|
||||
.filter(|&ch| self.is_allowed(ch))
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user