summaryrefslogtreecommitdiffstats
path: root/vendor/unicode-bidi/src/data_source.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:50 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:50 +0000
commit2e00214b3efbdfeefaa0fe9e8b8fd519de7adc35 (patch)
treed325add32978dbdc1db975a438b3a77d571b1ab8 /vendor/unicode-bidi/src/data_source.rs
parentReleasing progress-linux version 1.68.2+dfsg1-1~progress7.99u1. (diff)
downloadrustc-2e00214b3efbdfeefaa0fe9e8b8fd519de7adc35.tar.xz
rustc-2e00214b3efbdfeefaa0fe9e8b8fd519de7adc35.zip
Merging upstream version 1.69.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/unicode-bidi/src/data_source.rs')
-rw-r--r--vendor/unicode-bidi/src/data_source.rs30
1 files changed, 30 insertions, 0 deletions
diff --git a/vendor/unicode-bidi/src/data_source.rs b/vendor/unicode-bidi/src/data_source.rs
index 3958a255e..319ad53b0 100644
--- a/vendor/unicode-bidi/src/data_source.rs
+++ b/vendor/unicode-bidi/src/data_source.rs
@@ -9,8 +9,38 @@
use crate::BidiClass;
+/// This is the return value of [`BidiDataSource::bidi_matched_opening_bracket()`].
+///
+/// It represents the matching *normalized* opening bracket for a given bracket in a bracket pair,
+/// and whether or not that bracket is opening.
+#[derive(Debug, Copy, Clone)]
+pub struct BidiMatchedOpeningBracket {
+ /// The corresponding opening bracket in this bracket pair, normalized
+ ///
+ /// In case of opening brackets, this will be the bracket itself, except for when the bracket
+ /// is not normalized, in which case it will be the normalized form.
+ pub opening: char,
+ /// Whether or not the requested bracket was an opening bracket. True for opening
+ pub is_open: bool,
+}
+
/// This trait abstracts over a data source that is able to produce the Unicode Bidi class for a given
/// character
pub trait BidiDataSource {
fn bidi_class(&self, c: char) -> BidiClass;
+ /// 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.
+ ///
+ /// This effectively buckets brackets into equivalence classes keyed on the
+ /// normalized opening bracket.
+ ///
+ /// The default implementation will pull in a small amount of hardcoded data,
+ /// regardless of the `hardcoded-data` feature. This is in part for convenience
+ /// (since this data is small and changes less often), and in part so that this method can be
+ /// added without needing a breaking version bump.
+ /// Override this method in your custom data source to prevent the use of hardcoded data.
+ fn bidi_matched_opening_bracket(&self, c: char) -> Option<BidiMatchedOpeningBracket> {
+ crate::char_data::bidi_matched_opening_bracket(c)
+ }
}