diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:41 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:41 +0000 |
commit | 4f9fe856a25ab29345b90e7725509e9ee38a37be (patch) | |
tree | e4ffd8a9374cae7b21f7cbfb352927e0e074aff6 /vendor/unicode-bidi/src/char_data/mod.rs | |
parent | Adding upstream version 1.68.2+dfsg1. (diff) | |
download | rustc-5cd5bd4daf55da04d2c8e7c06c3067a027cfbfc2.tar.xz rustc-5cd5bd4daf55da04d2c8e7c06c3067a027cfbfc2.zip |
Adding upstream version 1.69.0+dfsg1.upstream/1.69.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | vendor/unicode-bidi/src/char_data/mod.rs | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/vendor/unicode-bidi/src/char_data/mod.rs b/vendor/unicode-bidi/src/char_data/mod.rs index a8b452788..4edf5b8f4 100644 --- a/vendor/unicode-bidi/src/char_data/mod.rs +++ b/vendor/unicode-bidi/src/char_data/mod.rs @@ -19,10 +19,10 @@ use core::cmp::Ordering::{Equal, Greater, Less}; #[cfg(feature = "hardcoded-data")] use self::tables::bidi_class_table; +use crate::data_source::BidiMatchedOpeningBracket; use crate::BidiClass::*; #[cfg(feature = "hardcoded-data")] use crate::BidiDataSource; - /// Hardcoded Bidi data that ships with the unicode-bidi crate. /// /// This can be enabled with the default `hardcoded-data` Cargo feature. @@ -42,6 +42,22 @@ pub fn bidi_class(c: char) -> BidiClass { bsearch_range_value_table(c, bidi_class_table) } +/// If this character is a bracket according to BidiBrackets.txt, +/// return the corresponding *normalized* *opening bracket* of the pair, +/// and whether or not it itself is an opening bracket. +pub(crate) fn bidi_matched_opening_bracket(c: char) -> Option<BidiMatchedOpeningBracket> { + for pair in self::tables::bidi_pairs_table { + if pair.0 == c || pair.1 == c { + let skeleton = pair.2.unwrap_or(pair.0); + return Some(BidiMatchedOpeningBracket { + opening: skeleton, + is_open: pair.0 == c, + }); + } + } + None +} + pub fn is_rtl(bidi_class: BidiClass) -> bool { match bidi_class { RLE | RLO | RLI => true, |