diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-02-16 01:11:56 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-02-16 01:11:56 +0000 |
commit | cbfaba6f5f9c94e7fcc9bf7f1fc7db16df2e6f44 (patch) | |
tree | ba149378c00d33edf2b1f48ebf6763aeb08bc733 | |
parent | 52035381e69d095280993f9e0768808571bb14e3 (diff) | |
parent | 87076c3b5a518f87e132b59a5fd1309051aab57b (diff) | |
download | unicode-bidi-cbfaba6f5f9c94e7fcc9bf7f1fc7db16df2e6f44.tar.gz |
Snap for 8188146 from 87076c3b5a518f87e132b59a5fd1309051aab57b to tm-frc-extservices-release
Change-Id: If3c7467266edcc81d1a010c75395f6b66fcc350b
-rw-r--r-- | .cargo_vcs_info.json | 5 | ||||
-rw-r--r-- | .travis.yml | 3 | ||||
-rw-r--r-- | Android.bp | 48 | ||||
-rw-r--r-- | Cargo.toml | 29 | ||||
-rw-r--r-- | Cargo.toml.orig | 27 | ||||
-rw-r--r-- | METADATA | 10 | ||||
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | TEST_MAPPING | 23 | ||||
-rw-r--r-- | src/char_data/mod.rs | 6 | ||||
-rw-r--r-- | src/deprecated.rs | 3 | ||||
-rw-r--r-- | src/explicit.rs | 13 | ||||
-rw-r--r-- | src/implicit.rs | 18 | ||||
-rw-r--r-- | src/level.rs | 9 | ||||
-rw-r--r-- | src/lib.rs | 106 | ||||
-rw-r--r-- | src/prepare.rs | 24 |
15 files changed, 140 insertions, 186 deletions
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json deleted file mode 100644 index 54bfe61..0000000 --- a/.cargo_vcs_info.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "git": { - "sha1": "2c89f8f02566cfaeb1266706b259c6c7c3aae8dd" - } -} diff --git a/.travis.yml b/.travis.yml index 7949019..76a90be 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,7 @@ rust: - nightly - beta - stable - - 1.31.0 + - 1.17.0 matrix: fast_finish: true @@ -15,6 +15,7 @@ matrix: - rust: nightly notifications: + webhooks: http://build.servo.org:54856/travis email: on_success: never @@ -40,15 +40,14 @@ license { rust_library { name: "libunicode_bidi", + // has rustc warnings host_supported: true, crate_name: "unicode_bidi", - cargo_env_compat: true, - cargo_pkg_version: "0.3.6", srcs: ["src/lib.rs"], - edition: "2018", - features: [ - "default", - "std", + edition: "2015", + features: ["default"], + rustlibs: [ + "libmatches", ], apex_available: [ "//apex_available:platform", @@ -57,24 +56,35 @@ rust_library { min_sdk_version: "29", } -rust_test { - name: "unicode-bidi_test_src_lib", - host_supported: true, +rust_defaults { + name: "unicode-bidi_defaults", crate_name: "unicode_bidi", - cargo_env_compat: true, - cargo_pkg_version: "0.3.6", + // has rustc warnings srcs: ["src/lib.rs"], test_suites: ["general-tests"], auto_gen_config: true, - test_options: { - unit_test: true, - }, - edition: "2018", - features: [ - "default", - "std", - ], + edition: "2015", + features: ["default"], rustlibs: [ + "libmatches", "libserde_test", ], } + +rust_test_host { + name: "unicode-bidi_host_test_src_lib", + defaults: ["unicode-bidi_defaults"], + test_options: { + unit_test: true, + }, +} + +rust_test { + name: "unicode-bidi_device_test_src_lib", + defaults: ["unicode-bidi_defaults"], +} + +// dependent_library ["feature_list"] +// matches-0.1.8 +// serde-1.0.125 "default,std" +// serde_test-1.0.125 @@ -3,7 +3,7 @@ # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies -# to registry (e.g., crates.io) dependencies +# to registry (e.g. crates.io) dependencies # # If you believe there's an error in this file please file an # issue against the rust-lang/cargo repository. If you're @@ -11,46 +11,39 @@ # will likely look very different (and much more reasonable) [package] -edition = "2018" name = "unicode-bidi" -version = "0.3.6" +version = "0.3.4" authors = ["The Servo Project Developers"] exclude = ["benches/**", "data/**", "examples/**", "tests/**", "tools/**"] description = "Implementation of the Unicode Bidirectional Algorithm" -documentation = "https://docs.rs/unicode-bidi/" -readme = "README.md" +documentation = "http://doc.servo.org/unicode_bidi/" keywords = ["rtl", "unicode", "text", "layout", "bidi"] -categories = ["no-std", "encoding", "text-processing"] license = "MIT / Apache-2.0" repository = "https://github.com/servo/unicode-bidi" [lib] name = "unicode_bidi" [dependencies.flame] -version = "0.2" +version = "0.1" optional = true [dependencies.flamer] -version = "0.4" +version = "0.1" optional = true [dependencies.serde] version = ">=0.8, <2.0" features = ["derive"] optional = true -default-features = false + +[dependencies.matches] +version = "0.1" [dev-dependencies.serde_test] version = ">=0.8, <2.0" [features] -bench_it = [] -default = ["std"] +with_serde = ["serde"] flame_it = ["flame", "flamer"] -std = [] unstable = [] -with_serde = ["serde"] -[badges.appveyor] -repository = "servo/unicode-bidi" - -[badges.travis-ci] -repository = "servo/unicode-bidi" +default = [] +bench_it = [] diff --git a/Cargo.toml.orig b/Cargo.toml.orig index 912ded6..abfcaac 100644 --- a/Cargo.toml.orig +++ b/Cargo.toml.orig @@ -1,19 +1,12 @@ [package] name = "unicode-bidi" -version = "0.3.6" +version = "0.3.4" authors = ["The Servo Project Developers"] license = "MIT / Apache-2.0" description = "Implementation of the Unicode Bidirectional Algorithm" repository = "https://github.com/servo/unicode-bidi" -documentation = "https://docs.rs/unicode-bidi/" +documentation = "http://doc.servo.org/unicode_bidi/" keywords = ["rtl", "unicode", "text", "layout", "bidi"] -readme="README.md" -edition = "2018" -categories = [ - "no-std", - "encoding", - "text-processing", -] # No data is shipped; benches, examples and tests also depend on data. exclude = [ @@ -24,26 +17,20 @@ exclude = [ "tools/**", ] -[badges] -travis-ci = { repository = "servo/unicode-bidi" } -appveyor = { repository = "servo/unicode-bidi" } - [lib] name = "unicode_bidi" [dependencies] -flame = { version = "0.2", optional = true } -flamer = { version = "0.4", optional = true } -serde = { version = ">=0.8, <2.0", default-features = false, optional = true, features = ["derive"] } +flame = { version = "0.1", optional = true } +flamer = { version = "0.1", optional = true } +matches = "0.1" +serde = { version = ">=0.8, <2.0", optional = true, features = ["derive"] } [dev-dependencies] serde_test = ">=0.8, <2.0" [features] -# Note: We don't actually use the `std` feature for anything other than making -# doctests work. But it may come in handy in the future. -default = ["std"] -std = [] +default = [] unstable = [] # travis-cargo needs it bench_it = [] flame_it = ["flame", "flamer"] @@ -7,13 +7,13 @@ third_party { } url { type: ARCHIVE - value: "https://static.crates.io/crates/unicode-bidi/unicode-bidi-0.3.6.crate" + value: "https://static.crates.io/crates/unicode-bidi/unicode-bidi-0.3.4.crate" } - version: "0.3.6" + version: "0.3.4" license_type: NOTICE last_upgrade_date { - year: 2021 - month: 9 - day: 22 + year: 2020 + month: 12 + day: 15 } } @@ -4,7 +4,7 @@ This crate implements the [Unicode Bidirectional Algorithm][tr9] for display of mixed right-to-left and left-to-right text. It is written in safe Rust, compatible with the current stable release. -[Documentation](https://docs.rs/unicode-bidi/) +[Documentation](http://doc.servo.org/unicode_bidi/) [![Travis-CI](https://travis-ci.org/servo/unicode-bidi.svg?branch=master)](https://travis-ci.org/servo/unicode-bidi) [![AppVeyor](https://img.shields.io/appveyor/ci/servo/unicode-bidi/master.svg)](https://ci.appveyor.com/project/servo/unicode-bidi) diff --git a/TEST_MAPPING b/TEST_MAPPING index 2f8032a..d1919fd 100644 --- a/TEST_MAPPING +++ b/TEST_MAPPING @@ -1,27 +1,8 @@ -// Generated by update_crate_tests.py for tests that depend on this crate. +// Generated by cargo2android.py for tests in Android.bp { - "imports": [ - { - "path": "external/rust/crates/quiche" - }, - { - "path": "external/rust/crates/url" - } - ], "presubmit": [ { - "name": "doh_unit_test" - }, - { - "name": "unicode-bidi_test_src_lib" - } - ], - "presubmit-rust": [ - { - "name": "doh_unit_test" - }, - { - "name": "unicode-bidi_test_src_lib" + "name": "unicode-bidi_device_test_src_lib" } ] } diff --git a/src/char_data/mod.rs b/src/char_data/mod.rs index c91bfad..4899a71 100644 --- a/src/char_data/mod.rs +++ b/src/char_data/mod.rs @@ -13,11 +13,11 @@ mod tables; pub use self::tables::{BidiClass, UNICODE_VERSION}; -use core::cmp::Ordering::{Equal, Less, Greater}; -use core::char; +use std::cmp::Ordering::{Equal, Less, Greater}; +use std::char; use self::tables::bidi_class_table; -use crate::BidiClass::*; +use BidiClass::*; /// Find the `BidiClass` of a single char. pub fn bidi_class(c: char) -> BidiClass { diff --git a/src/deprecated.rs b/src/deprecated.rs index 491436a..4d4b76e 100644 --- a/src/deprecated.rs +++ b/src/deprecated.rs @@ -9,7 +9,8 @@ //! This module holds deprecated assets only. -use alloc::vec::Vec; +// Doesn't worth updating API here +#![cfg_attr(feature="cargo-clippy", allow(needless_pass_by_value))] use super::*; diff --git a/src/explicit.rs b/src/explicit.rs index ec39dee..4f6f22f 100644 --- a/src/explicit.rs +++ b/src/explicit.rs @@ -11,16 +11,16 @@ //! //! <http://www.unicode.org/reports/tr9/#Explicit_Levels_and_Directions> -use alloc::vec::Vec; - -use super::char_data::{BidiClass::{self, *}, is_rtl}; +use super::char_data::{BidiClass, is_rtl}; use super::level::Level; +use BidiClass::*; + /// Compute explicit embedding levels for one paragraph of text (X1-X8). /// /// `processing_classes[i]` must contain the `BidiClass` of the char at byte index `i`, /// for each char in `text`. -#[cfg_attr(feature = "flame_it", flamer::flame)] +#[cfg_attr(feature = "flame_it", flame)] pub fn compute( text: &str, para_level: Level, @@ -46,10 +46,7 @@ pub fn compute( let last_level = stack.last().level; // X5a-X5c: Isolate initiators get the level of the last entry on the stack. - let is_isolate = match original_classes[i] { - RLI | LRI | FSI => true, - _ => false, - }; + let is_isolate = matches!(original_classes[i], RLI | LRI | FSI); if is_isolate { levels[i] = last_level; match stack.last().status { diff --git a/src/implicit.rs b/src/implicit.rs index 2bb3581..4344ea3 100644 --- a/src/implicit.rs +++ b/src/implicit.rs @@ -9,17 +9,18 @@ //! 3.3.4 - 3.3.6. Resolve implicit levels and types. -use core::cmp::max; -use alloc::vec::Vec; +use std::cmp::max; -use super::char_data::BidiClass::{self, *}; +use super::char_data::BidiClass; use super::prepare::{IsolatingRunSequence, LevelRun, not_removed_by_x9, removed_by_x9}; use super::level::Level; +use BidiClass::*; + /// 3.3.4 Resolving Weak Types /// /// <http://www.unicode.org/reports/tr9/#Resolving_Weak_Types> -#[cfg_attr(feature = "flame_it", flamer::flame)] +#[cfg_attr(feature = "flame_it", flame)] pub fn resolve_weak(sequence: &IsolatingRunSequence, processing_classes: &mut [BidiClass]) { // FIXME (#8): This function applies steps W1-W6 in a single pass. This can produce // incorrect results in cases where a "later" rule changes the value of `prev_class` seen @@ -134,7 +135,7 @@ pub fn resolve_weak(sequence: &IsolatingRunSequence, processing_classes: &mut [B /// 3.3.5 Resolving Neutral Types /// /// <http://www.unicode.org/reports/tr9/#Resolving_Neutral_Types> -#[cfg_attr(feature = "flame_it", flamer::flame)] +#[cfg_attr(feature = "flame_it", flame)] pub fn resolve_neutral( sequence: &IsolatingRunSequence, levels: &[Level], @@ -199,7 +200,7 @@ pub fn resolve_neutral( /// Returns the maximum embedding level in the paragraph. /// /// <http://www.unicode.org/reports/tr9/#Resolving_Implicit_Levels> -#[cfg_attr(feature = "flame_it", flamer::flame)] +#[cfg_attr(feature = "flame_it", flame)] pub fn resolve_levels(original_classes: &[BidiClass], levels: &mut [Level]) -> Level { let mut max_level = Level::ltr(); @@ -223,8 +224,5 @@ pub fn resolve_levels(original_classes: &[BidiClass], levels: &mut [Level]) -> L /// <http://www.unicode.org/reports/tr9/#NI> #[allow(non_snake_case)] fn is_NI(class: BidiClass) -> bool { - match class { - B | S | WS | ON | FSI | LRI | RLI | PDI => true, - _ => false, - } + matches!(class, B | S | WS | ON | FSI | LRI | RLI | PDI) } diff --git a/src/level.rs b/src/level.rs index c1adf1f..1c195a9 100644 --- a/src/level.rs +++ b/src/level.rs @@ -13,9 +13,7 @@ //! //! <http://www.unicode.org/reports/tr9/#BD2> -use alloc::vec::Vec; -use core::convert::{From, Into}; -use alloc::string::{String, ToString}; +use std::convert::{From, Into}; use super::char_data::BidiClass; @@ -30,7 +28,7 @@ use super::char_data::BidiClass; /// /// <http://www.unicode.org/reports/tr9/#BD2> #[derive(Copy, Clone, Debug, Eq, Ord, PartialEq, PartialOrd)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub struct Level(u8); pub const LTR_LEVEL: Level = Level(0); @@ -330,8 +328,7 @@ mod tests { #[test] fn test_into() { let level = Level::rtl(); - let number: u8 = level.into(); - assert_eq!(1u8, number); + assert_eq!(1u8, level.into()); } #[test] @@ -53,23 +53,27 @@ //! ]); //! ``` //! -//! # Features -//! -//! - `std`: Enabled by default, but can be disabled to make `unicode_bidi` -//! `#![no_std]` + `alloc` compatible. -//! - `serde`: Adds [`serde::Serialize`] and [`serde::Deserialize`] -//! implementations to relevant types. -//! //! [tr9]: <http://www.unicode.org/reports/tr9/> #![forbid(unsafe_code)] -#![no_std] -// We need to link to std to make doc tests work on older Rust versions -#![cfg(feature = "std")] -extern crate std; +#![cfg_attr(feature="flame_it", feature(plugin, custom_attribute))] +#![cfg_attr(feature="flame_it", plugin(flamer))] + + #[macro_use] -extern crate alloc; +extern crate matches; + +#[cfg(feature = "serde")] +#[macro_use] +extern crate serde; + +#[cfg(all(feature = "serde", test))] +extern crate serde_test; + +#[cfg(feature = "flame_it")] +extern crate flame; + pub mod deprecated; pub mod format_chars; @@ -80,19 +84,18 @@ mod explicit; mod implicit; mod prepare; -pub use crate::char_data::{BidiClass, bidi_class, UNICODE_VERSION}; -pub use crate::level::{Level, LTR_LEVEL, RTL_LEVEL}; -pub use crate::prepare::LevelRun; +pub use char_data::{BidiClass, bidi_class, UNICODE_VERSION}; +pub use level::{Level, LTR_LEVEL, RTL_LEVEL}; +pub use prepare::LevelRun; -use alloc::borrow::Cow; -use alloc::vec::Vec; -use alloc::string::String; -use core::cmp::{max, min}; -use core::iter::repeat; -use core::ops::Range; +use std::borrow::Cow; +use std::cmp::{max, min}; +use std::iter::repeat; +use std::ops::Range; + +use BidiClass::*; +use format_chars as chars; -use crate::BidiClass::*; -use crate::format_chars as chars; /// Bidi information about a single paragraph #[derive(Debug, PartialEq)] @@ -132,8 +135,8 @@ impl<'text> InitialInfo<'text> { /// Also sets the class for each First Strong Isolate initiator (FSI) to LRI or RLI if a strong /// character is found before the matching PDI. If no strong character is found, the class will /// remain FSI, and it's up to later stages to treat these as LRI when needed. - #[cfg_attr(feature = "flame_it", flamer::flame)] - pub fn new(text: &str, default_para_level: Option<Level>) -> InitialInfo<'_> { + #[cfg_attr(feature = "flame_it", flame)] + pub fn new(text: &str, default_para_level: Option<Level>) -> InitialInfo { let mut original_classes = Vec::with_capacity(text.len()); // The stack contains the starting byte index for each nested isolate we're inside. @@ -258,8 +261,8 @@ impl<'text> BidiInfo<'text> { /// text that is entirely LTR. See the `nsBidi` class from Gecko for comparison. /// /// TODO: Support auto-RTL base direction - #[cfg_attr(feature = "flame_it", flamer::flame)] - pub fn new(text: &str, default_para_level: Option<Level>) -> BidiInfo<'_> { + #[cfg_attr(feature = "flame_it", flame)] + pub fn new(text: &str, default_para_level: Option<Level>) -> BidiInfo { let InitialInfo { original_classes, paragraphs, @@ -306,15 +309,15 @@ impl<'text> BidiInfo<'text> { /// Re-order a line based on resolved levels and return only the embedding levels, one `Level` /// per *byte*. - #[cfg_attr(feature = "flame_it", flamer::flame)] + #[cfg_attr(feature = "flame_it", flame)] pub fn reordered_levels(&self, para: &ParagraphInfo, line: Range<usize>) -> Vec<Level> { - let (levels, _) = self.visual_runs(para, line); + let (levels, _) = self.visual_runs(para, line.clone()); levels } /// Re-order a line based on resolved levels and return only the embedding levels, one `Level` /// per *character*. - #[cfg_attr(feature = "flame_it", flamer::flame)] + #[cfg_attr(feature = "flame_it", flame)] pub fn reordered_levels_per_char( &self, para: &ParagraphInfo, @@ -326,13 +329,13 @@ impl<'text> BidiInfo<'text> { /// Re-order a line based on resolved levels and return the line in display order. - #[cfg_attr(feature = "flame_it", flamer::flame)] + #[cfg_attr(feature = "flame_it", flame)] pub fn reorder_line(&self, para: &ParagraphInfo, line: Range<usize>) -> Cow<'text, str> { let (levels, runs) = self.visual_runs(para, line.clone()); // If all isolating run sequences are LTR, no reordering is needed if runs.iter().all(|run| levels[run.start].is_ltr()) { - return self.text[line].into(); + return self.text[line.clone()].into(); } let mut result = String::with_capacity(line.len()); @@ -351,7 +354,7 @@ impl<'text> BidiInfo<'text> { /// `line` is a range of bytes indices within `levels`. /// /// <http://www.unicode.org/reports/tr9/#Reordering_Resolved_Levels> - #[cfg_attr(feature = "flame_it", flamer::flame)] + #[cfg_attr(feature = "flame_it", flame)] pub fn visual_runs( &self, para: &ParagraphInfo, @@ -361,8 +364,6 @@ impl<'text> BidiInfo<'text> { assert!(line.end <= self.levels.len()); let mut levels = self.levels.clone(); - let line_classes = &self.original_classes[line.clone()]; - let line_levels = &mut levels[line.clone()]; // Reset some whitespace chars to paragraph level. // <http://www.unicode.org/reports/tr9/#L1> @@ -370,7 +371,7 @@ impl<'text> BidiInfo<'text> { let mut reset_from: Option<usize> = Some(0); let mut reset_to: Option<usize> = None; for (i, c) in line_str.char_indices() { - match line_classes[i] { + match self.original_classes[i] { // Ignored by X9 RLE | LRE | RLO | LRO | PDF | BN => {} // Segment separator, Paragraph separator @@ -392,16 +393,18 @@ impl<'text> BidiInfo<'text> { } } if let (Some(from), Some(to)) = (reset_from, reset_to) { - for level in &mut line_levels[from..to] { - *level = para.level; + #[cfg_attr(feature = "cargo-clippy", allow(needless_range_loop))] + for j in from..to { + levels[j] = para.level; } reset_from = None; reset_to = None; } } if let Some(from) = reset_from { - for level in &mut line_levels[from..] { - *level = para.level; + #[cfg_attr(feature = "cargo-clippy", allow(needless_range_loop))] + for j in from..line_str.len() { + levels[j] = para.level; } } @@ -476,7 +479,7 @@ impl<'text> BidiInfo<'text> { /// /// The levels assigned to these characters are not specified by the algorithm. This function /// assigns each one the level of the previous character, to avoid breaking level runs. -#[cfg_attr(feature = "flame_it", flamer::flame)] +#[cfg_attr(feature = "flame_it", flame)] fn assign_levels_to_removed_chars(para_level: Level, classes: &[BidiClass], levels: &mut [Level]) { for i in 0..levels.len() { if prepare::removed_by_x9(classes[i]) { @@ -671,7 +674,7 @@ mod tests { } ); - // BidiTest:69635 (AL ET EN) + /// BidiTest:69635 (AL ET EN) let bidi_info = BidiInfo::new("\u{060B}\u{20CF}\u{06F9}", None); assert_eq!(bidi_info.original_classes, vec![AL, AL, ET, ET, ET, EN, EN]); } @@ -700,7 +703,7 @@ mod tests { assert_eq!(BidiInfo::new("אבּג\n123", None).has_rtl(), true); } - fn reorder_paras(text: &str) -> Vec<Cow<'_, str>> { + fn reorder_paras(text: &str) -> Vec<Cow<str>> { let bidi_info = BidiInfo::new(text, None); bidi_info .paragraphs @@ -711,22 +714,22 @@ mod tests { #[test] fn test_reorder_line() { - // Bidi_Class: L L L B L L L B L L L + /// Bidi_Class: L L L B L L L B L L L assert_eq!( reorder_paras("abc\ndef\nghi"), vec!["abc\n", "def\n", "ghi"] ); - // Bidi_Class: L L EN B L L EN B L L EN + /// Bidi_Class: L L EN B L L EN B L L EN assert_eq!( reorder_paras("ab1\nde2\ngh3"), vec!["ab1\n", "de2\n", "gh3"] ); - // Bidi_Class: L L L B AL AL AL + /// Bidi_Class: L L L B AL AL AL assert_eq!(reorder_paras("abc\nابج"), vec!["abc\n", "جبا"]); - // Bidi_Class: AL AL AL B L L L + /// Bidi_Class: AL AL AL B L L L assert_eq!(reorder_paras("ابج\nabc"), vec!["\nجبا", "abc"]); assert_eq!(reorder_paras("1.-2"), vec!["1.-2"]); @@ -809,7 +812,7 @@ mod tests { #[test] fn test_reordered_levels() { - // BidiTest:946 (LRI PDI) + /// BidiTest:946 (LRI PDI) let text = "\u{2067}\u{2069}"; assert_eq!( reordered_levels_for_paras(text), @@ -820,13 +823,6 @@ mod tests { vec![Level::vec(&[0, 0])] ); - let text = "aa טֶ"; - let bidi_info = BidiInfo::new(text, None); - assert_eq!( - bidi_info.reordered_levels(&bidi_info.paragraphs[0], 3..7), - Level::vec(&[0, 0, 0, 1, 1, 1, 1]), - ) - /* TODO /// BidiTest:69635 (AL ET EN) let text = "\u{060B}\u{20CF}\u{06F9}"; diff --git a/src/prepare.rs b/src/prepare.rs index 752087b..7983962 100644 --- a/src/prepare.rs +++ b/src/prepare.rs @@ -11,13 +11,14 @@ //! //! <http://www.unicode.org/reports/tr9/#Preparations_for_Implicit_Processing> -use core::cmp::max; -use core::ops::Range; -use alloc::vec::Vec; +use std::cmp::max; +use std::ops::Range; -use super::BidiClass::{self, *}; +use super::char_data::BidiClass; use super::level::Level; +use BidiClass::*; + /// A maximal substring of characters with the same embedding level. /// /// Represented as a range of byte indices. @@ -40,7 +41,7 @@ pub struct IsolatingRunSequence { /// whose matching PDI is the first character of the next level run in the sequence. /// /// Note: This function does *not* return the sequences in order by their first characters. -#[cfg_attr(feature = "flame_it", flamer::flame)] +#[cfg_attr(feature = "flame_it", flame)] pub fn isolating_run_sequences( para_level: Level, original_classes: &[BidiClass], @@ -73,7 +74,7 @@ pub fn isolating_run_sequences( sequence.push(run); - if let RLI | LRI | FSI = end_class { + if matches!(end_class, RLI | LRI | FSI) { // Resume this sequence after the isolate. stack.push(sequence); } else { @@ -113,7 +114,7 @@ pub fn isolating_run_sequences( }; // Get the level of the next non-removed char after the runs. - let succ_level = if let RLI | LRI | FSI = original_classes[end_of_seq - 1] { + let succ_level = if matches!(original_classes[end_of_seq - 1], RLI | LRI | FSI) { para_level } else { match original_classes[end_of_seq..].iter().position( @@ -163,10 +164,7 @@ fn level_runs(levels: &[Level], original_classes: &[BidiClass]) -> Vec<LevelRun> /// /// <http://www.unicode.org/reports/tr9/#X9> pub fn removed_by_x9(class: BidiClass) -> bool { - match class { - RLE | LRE | RLO | LRO | PDF | BN => true, - _ => false, - } + matches!(class, RLE | LRE | RLO | LRO | PDF | BN) } // For use as a predicate for `position` / `rposition` @@ -188,7 +186,7 @@ mod tests { } // From <http://www.unicode.org/reports/tr9/#BD13> - #[rustfmt::skip] + #[cfg_attr(rustfmt, rustfmt_skip)] #[test] fn test_isolating_run_sequences() { @@ -233,7 +231,7 @@ mod tests { } // From <http://www.unicode.org/reports/tr9/#X10> - #[rustfmt::skip] + #[cfg_attr(rustfmt, rustfmt_skip)] #[test] fn test_isolating_run_sequences_sos_and_eos() { |