@@ -6,26 +6,27 @@ use super::{
66 Specificity ,
77} ;
88use selectors:: NthIndexCache ;
9- use std:: iter:: Zip ;
109
1110/// Compile selectors from a string and create an element iterator that yields elements matching these selectors.
1211#[ inline]
1312pub ( crate ) fn select < ' a , ' b , ' c > (
1413 document : & ' a Document ,
1514 selectors : & ' b str ,
16- caches : & ' c mut [ NthIndexCache ] ,
15+ caches : & ' c mut NthIndexCache ,
1716) -> Result < Select < ' a , ' c > , ParseError < ' b > > {
1817 Selectors :: compile ( selectors) . map ( |selectors| Select {
1918 document,
20- iter : document. elements . iter ( ) . zip ( caches. iter_mut ( ) ) ,
19+ caches,
20+ iter : document. elements . iter ( ) ,
2121 selectors,
2222 } )
2323}
2424
2525/// An element iterator adaptor that yields elements matching given selectors.
2626pub ( crate ) struct Select < ' a , ' c > {
2727 document : & ' a Document ,
28- iter : Zip < std:: slice:: Iter < ' a , NodeId > , std:: slice:: IterMut < ' c , NthIndexCache > > ,
28+ caches : & ' c mut NthIndexCache ,
29+ iter : std:: slice:: Iter < ' a , NodeId > ,
2930 /// The selectors to be matched.
3031 selectors : Selectors ,
3132}
@@ -43,13 +44,13 @@ impl<'a> Iterator for Select<'a, '_> {
4344
4445 #[ inline]
4546 fn next ( & mut self ) -> Option < Element < ' a > > {
46- for ( element_id, cache ) in self . iter . by_ref ( ) {
47+ for element_id in self . iter . by_ref ( ) {
4748 let NodeData :: Element { element, .. } = & self . document [ * element_id] . data else {
4849 unreachable ! ( "Element ids always point to element nodes" )
4950 } ;
5051 let element = Element :: new ( self . document , * element_id, element) ;
5152 for selector in self . selectors . iter ( ) {
52- if element. matches ( selector, cache ) {
53+ if element. matches ( selector, self . caches ) {
5354 return Some ( element) ;
5455 }
5556 }
0 commit comments