6060#![ cfg_attr( feature="flame_it" , feature( plugin, custom_attribute) ) ]
6161#![ cfg_attr( feature="flame_it" , plugin( flamer) ) ]
6262
63-
64- #[ macro_use]
65- extern crate matches;
66-
67- #[ cfg( feature = "serde" ) ]
68- #[ macro_use]
69- extern crate serde;
70-
71- #[ cfg( all( feature = "serde" , test) ) ]
72- extern crate serde_test;
73-
74- #[ cfg( feature = "flame_it" ) ]
75- extern crate flame;
76-
77-
7863pub mod deprecated;
7964pub mod format_chars;
8065pub mod level;
@@ -84,18 +69,17 @@ mod explicit;
8469mod implicit;
8570mod prepare;
8671
87- pub use char_data:: { BidiClass , bidi_class, UNICODE_VERSION } ;
88- pub use level:: { Level , LTR_LEVEL , RTL_LEVEL } ;
89- pub use prepare:: LevelRun ;
72+ pub use crate :: char_data:: { BidiClass , bidi_class, UNICODE_VERSION } ;
73+ pub use crate :: level:: { Level , LTR_LEVEL , RTL_LEVEL } ;
74+ pub use crate :: prepare:: LevelRun ;
9075
9176use std:: borrow:: Cow ;
9277use std:: cmp:: { max, min} ;
9378use std:: iter:: repeat;
9479use std:: ops:: Range ;
9580
96- use BidiClass :: * ;
97- use format_chars as chars;
98-
81+ use crate :: BidiClass :: * ;
82+ use crate :: format_chars as chars;
9983
10084/// Bidi information about a single paragraph
10185#[ derive( Debug , PartialEq ) ]
@@ -136,7 +120,7 @@ impl<'text> InitialInfo<'text> {
136120 /// character is found before the matching PDI. If no strong character is found, the class will
137121 /// remain FSI, and it's up to later stages to treat these as LRI when needed.
138122 #[ cfg_attr( feature = "flame_it" , flame) ]
139- pub fn new ( text : & str , default_para_level : Option < Level > ) -> InitialInfo {
123+ pub fn new ( text : & str , default_para_level : Option < Level > ) -> InitialInfo < ' _ > {
140124 let mut original_classes = Vec :: with_capacity ( text. len ( ) ) ;
141125
142126 // The stack contains the starting byte index for each nested isolate we're inside.
@@ -262,7 +246,7 @@ impl<'text> BidiInfo<'text> {
262246 ///
263247 /// TODO: Support auto-RTL base direction
264248 #[ cfg_attr( feature = "flame_it" , flame) ]
265- pub fn new ( text : & str , default_para_level : Option < Level > ) -> BidiInfo {
249+ pub fn new ( text : & str , default_para_level : Option < Level > ) -> BidiInfo < ' _ > {
266250 let InitialInfo {
267251 original_classes,
268252 paragraphs,
@@ -311,7 +295,7 @@ impl<'text> BidiInfo<'text> {
311295 /// per *byte*.
312296 #[ cfg_attr( feature = "flame_it" , flame) ]
313297 pub fn reordered_levels ( & self , para : & ParagraphInfo , line : Range < usize > ) -> Vec < Level > {
314- let ( levels, _) = self . visual_runs ( para, line. clone ( ) ) ;
298+ let ( levels, _) = self . visual_runs ( para, line) ;
315299 levels
316300 }
317301
@@ -335,7 +319,7 @@ impl<'text> BidiInfo<'text> {
335319
336320 // If all isolating run sequences are LTR, no reordering is needed
337321 if runs. iter ( ) . all ( |run| levels[ run. start ] . is_ltr ( ) ) {
338- return self . text [ line. clone ( ) ] . into ( ) ;
322+ return self . text [ line] . into ( ) ;
339323 }
340324
341325 let mut result = String :: with_capacity ( line. len ( ) ) ;
@@ -395,18 +379,16 @@ impl<'text> BidiInfo<'text> {
395379 }
396380 }
397381 if let ( Some ( from) , Some ( to) ) = ( reset_from, reset_to) {
398- #[ cfg_attr( feature = "cargo-clippy" , allow( needless_range_loop) ) ]
399- for j in from..to {
400- line_levels[ j] = para. level ;
382+ for level in & mut line_levels[ from..to] {
383+ * level = para. level ;
401384 }
402385 reset_from = None ;
403386 reset_to = None ;
404387 }
405388 }
406389 if let Some ( from) = reset_from {
407- #[ cfg_attr( feature = "cargo-clippy" , allow( needless_range_loop) ) ]
408- for j in from..line_str. len ( ) {
409- line_levels[ j] = para. level ;
390+ for level in & mut line_levels[ from..] {
391+ * level = para. level ;
410392 }
411393 }
412394
@@ -676,7 +658,7 @@ mod tests {
676658 }
677659 ) ;
678660
679- /// BidiTest:69635 (AL ET EN)
661+ // BidiTest:69635 (AL ET EN)
680662 let bidi_info = BidiInfo :: new ( "\u{060B} \u{20CF} \u{06F9} " , None ) ;
681663 assert_eq ! ( bidi_info. original_classes, vec![ AL , AL , ET , ET , ET , EN , EN ] ) ;
682664 }
@@ -705,7 +687,7 @@ mod tests {
705687 assert_eq ! ( BidiInfo :: new( "אבּג\n 123" , None ) . has_rtl( ) , true ) ;
706688 }
707689
708- fn reorder_paras ( text : & str ) -> Vec < Cow < str > > {
690+ fn reorder_paras ( text : & str ) -> Vec < Cow < ' _ , str > > {
709691 let bidi_info = BidiInfo :: new ( text, None ) ;
710692 bidi_info
711693 . paragraphs
@@ -716,22 +698,22 @@ mod tests {
716698
717699 #[ test]
718700 fn test_reorder_line ( ) {
719- /// Bidi_Class: L L L B L L L B L L L
701+ // Bidi_Class: L L L B L L L B L L L
720702 assert_eq ! (
721703 reorder_paras( "abc\n def\n ghi" ) ,
722704 vec![ "abc\n " , "def\n " , "ghi" ]
723705 ) ;
724706
725- /// Bidi_Class: L L EN B L L EN B L L EN
707+ // Bidi_Class: L L EN B L L EN B L L EN
726708 assert_eq ! (
727709 reorder_paras( "ab1\n de2\n gh3" ) ,
728710 vec![ "ab1\n " , "de2\n " , "gh3" ]
729711 ) ;
730712
731- /// Bidi_Class: L L L B AL AL AL
713+ // Bidi_Class: L L L B AL AL AL
732714 assert_eq ! ( reorder_paras( "abc\n ابج" ) , vec![ "abc\n " , "جبا" ] ) ;
733715
734- /// Bidi_Class: AL AL AL B L L L
716+ // Bidi_Class: AL AL AL B L L L
735717 assert_eq ! ( reorder_paras( "ابج\n abc" ) , vec![ "\n جبا" , "abc" ] ) ;
736718
737719 assert_eq ! ( reorder_paras( "1.-2" ) , vec![ "1.-2" ] ) ;
@@ -814,7 +796,7 @@ mod tests {
814796 #[ test]
815797 fn test_reordered_levels ( ) {
816798
817- /// BidiTest:946 (LRI PDI)
799+ // BidiTest:946 (LRI PDI)
818800 let text = "\u{2067} \u{2069} " ;
819801 assert_eq ! (
820802 reordered_levels_for_paras( text) ,
0 commit comments