1 // This file is part of ICU4X. For terms of use, please see the file 2 // called LICENSE at the top level of the ICU4X source tree 3 // (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ). 4 5 use icu_collections::codepointinvlist::CodePointInversionListBuilder; 6 7 /// An object that accepts characters and/or strings 8 /// to be used with [`CaseMapCloserBorrowed::add_string_case_closure_to()`] 9 /// and [`CaseMapCloserBorrowed::add_case_closure_to()`]. 10 /// 11 /// Usually this object 12 /// will be some kind of set over codepoints and strings, or something that 13 /// can be built into one. 14 /// 15 /// An implementation is provided for [`CodePointInversionListBuilder`], but users are encouraged 16 /// to implement this trait on their own collections as needed. 17 /// 18 /// [`CaseMapCloserBorrowed::add_string_case_closure_to()`]: crate::CaseMapCloserBorrowed::add_string_case_closure_to 19 /// [`CaseMapCloserBorrowed::add_case_closure_to()`]: crate::CaseMapCloserBorrowed::add_case_closure_to 20 pub trait ClosureSink { 21 /// Add a character to the set add_char(&mut self, c: char)22 fn add_char(&mut self, c: char); 23 /// Add a string to the set add_string(&mut self, string: &str)24 fn add_string(&mut self, string: &str); 25 } 26 27 impl ClosureSink for CodePointInversionListBuilder { add_char(&mut self, c: char)28 fn add_char(&mut self, c: char) { 29 self.add_char(c) 30 } 31 32 // The current version of CodePointInversionList doesn't include strings. 33 // Trying to add a string is a no-op that will be optimized away. 34 #[inline] add_string(&mut self, _string: &str)35 fn add_string(&mut self, _string: &str) {} 36 } 37