From ccda52f4d113209af8033d94d91172d82b598d76 Mon Sep 17 00:00:00 2001 From: Jonathan Kew Date: Mon, 30 Oct 2023 20:28:15 +0000 Subject: [PATCH] [utf-16] Move iterator bounds to the TextSource trait --- src/explicit.rs | 4 +--- src/implicit.rs | 10 ++-------- src/lib.rs | 21 ++++++--------------- 3 files changed, 9 insertions(+), 26 deletions(-) diff --git a/src/explicit.rs b/src/explicit.rs index d840a7a..d4ad897 100644 --- a/src/explicit.rs +++ b/src/explicit.rs @@ -31,9 +31,7 @@ pub fn compute<'a, T: TextSource<'a> + ?Sized>( original_classes: &[BidiClass], levels: &mut [Level], processing_classes: &mut [BidiClass], -) where - >::IndexLenIter: Iterator, -{ +) { assert_eq!(text.len(), original_classes.len()); // diff --git a/src/implicit.rs b/src/implicit.rs index 2265f7a..0311053 100644 --- a/src/implicit.rs +++ b/src/implicit.rs @@ -255,10 +255,7 @@ pub fn resolve_neutral<'a, D: BidiDataSource, T: TextSource<'a> + ?Sized>( levels: &[Level], original_classes: &[BidiClass], processing_classes: &mut [BidiClass], -) where - >::CharIndexIter: Iterator, - >::CharIter: Iterator, -{ +) { // e = embedding direction let e: BidiClass = levels[sequence.runs[0].start].bidi_class(); let not_e = if e == BidiClass::L { @@ -487,10 +484,7 @@ fn identify_bracket_pairs<'a, T: TextSource<'a> + ?Sized, D: BidiDataSource>( data_source: &D, run_sequence: &IsolatingRunSequence, original_classes: &[BidiClass], -) -> Vec -where - >::CharIndexIter: Iterator, -{ +) -> Vec { let mut ret = vec![]; let mut stack = vec![]; diff --git a/src/lib.rs b/src/lib.rs index 9d65c2e..00122df 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -108,9 +108,9 @@ use crate::BidiClass::*; /// (For internal unicode-bidi use; API may be unstable.) /// This trait is sealed and cannot be implemented for types outside this crate. pub trait TextSource<'text>: private::Sealed { - type CharIter; - type CharIndexIter; - type IndexLenIter; + type CharIter: Iterator; + type CharIndexIter: Iterator; + type IndexLenIter: Iterator; /// Return the length of the text in code units. #[doc(hidden)] @@ -283,10 +283,7 @@ fn compute_initial_info<'a, D: BidiDataSource, T: TextSource<'a> + ?Sized>( data_source: &D, text: &'a T, default_para_level: Option, -) -> (Vec, Vec, Vec) -where - >::CharIndexIter: Iterator, -{ +) -> (Vec, Vec, Vec) { let mut original_classes = Vec::with_capacity(text.len()); // The stack contains the starting code unit index for each nested isolate we're inside. @@ -835,11 +832,7 @@ fn compute_bidi_info_for_para<'a, D: BidiDataSource, T: TextSource<'a> + ?Sized> original_classes: &[BidiClass], processing_classes: &mut [BidiClass], levels: &mut Vec, -) where - >::CharIndexIter: Iterator, - >::CharIter: Iterator, - >::IndexLenIter: Iterator, -{ +) { let new_len = levels.len() + para.range.len(); levels.resize(new_len, para.level); if para.level == LTR_LEVEL && is_pure_ltr { @@ -886,9 +879,7 @@ fn reorder_levels<'a, T: TextSource<'a> + ?Sized>( line_levels: &mut [Level], line_text: &'a T, para_level: Level, -) where - >::CharIndexIter: Iterator, -{ +) { // Reset some whitespace chars to paragraph level. // let mut reset_from: Option = Some(0);