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 #[cfg(feature = "alloc")] 6 use crate::extensions::unicode::Value; 7 #[cfg(feature = "alloc")] 8 use crate::preferences::extensions::unicode::errors::PreferencesParseError; 9 #[cfg(feature = "alloc")] 10 use crate::preferences::extensions::unicode::struct_keyword; 11 #[cfg(feature = "alloc")] 12 use crate::subtags::Script; 13 #[cfg(feature = "alloc")] 14 use alloc::vec::Vec; 15 #[cfg(feature = "alloc")] 16 use core::str::FromStr; 17 18 #[cfg(feature = "alloc")] 19 struct_keyword!( 20 /// A Unicode Dictionary Break Exclusion Identifier specifies 21 /// scripts to be excluded from dictionary-based text break (for words and lines). 22 /// 23 /// The valid values are of one or more items of type [`Script`](crate::subtags::Script). 24 DictionaryBreakScriptExclusions, 25 "dx", 26 Vec<Script>, 27 |input: Value| { 28 input 29 .into_iter() 30 .map(|s| { 31 Script::from_str(s.as_str()).map_err(|_| PreferencesParseError::InvalidKeywordValue) 32 }) 33 .collect::<Result<_, _>>() 34 .map(Self) 35 }, 36 |input: DictionaryBreakScriptExclusions| { 37 input.0.into_iter().map(Into::into).collect() 38 } 39 ); 40