5 parse_codepoint_association
, CodepointIter
, Codepoints
, UcdFile
,
8 use crate::error
::Error
;
10 /// A single row in the `extracted/DerivedBidiClass.txt` file.
12 /// This file gives the derived values of the Bidi_Class property.
13 #[derive(Clone, Debug, Default, Eq, PartialEq)]
14 pub struct DerivedBidiClass
{
15 /// The codepoint or codepoint range for this entry.
16 pub codepoints
: Codepoints
,
17 /// The derived Bidi_Class of the codepoints in this entry.
18 pub bidi_class
: String
,
21 impl UcdFile
for DerivedBidiClass
{
22 fn relative_file_path() -> &'
static Path
{
23 Path
::new("extracted/DerivedBidiClass.txt")
27 impl UcdFileByCodepoint
for DerivedBidiClass
{
28 fn codepoints(&self) -> CodepointIter
{
29 self.codepoints
.into_iter()
33 impl FromStr
for DerivedBidiClass
{
36 fn from_str(line
: &str) -> Result
<DerivedBidiClass
, Error
> {
37 let (codepoints
, bidi_class
) = parse_codepoint_association(line
)?
;
38 Ok(DerivedBidiClass { codepoints, bidi_class: bidi_class.to_string() }
)
44 use super::DerivedBidiClass
;
48 let line
= "00B5 ; L # L& MICRO SIGN\n";
49 let row
: DerivedBidiClass
= line
.parse().unwrap();
50 assert_eq
!(row
.codepoints
, 0x00B5);
51 assert_eq
!(row
.bidi_class
, "L");
56 let line
= "0030..0039 ; EN # Nd [10] DIGIT ZERO..DIGIT NINE\n";
57 let row
: DerivedBidiClass
= line
.parse().unwrap();
58 assert_eq
!(row
.codepoints
, (0x0030, 0x0039));
59 assert_eq
!(row
.bidi_class
, "EN");