@@ -98,22 +98,16 @@ impl SerializedSearchIndex {
9898 let root_path = doc_root. join ( format ! ( "search.index/root{resource_suffix}.js" ) ) ;
9999 let column_path = doc_root. join ( format ! ( "search.index/{column_name}/" ) ) ;
100100
101- struct Consumer < ' col > ( & ' col mut Vec < String > ) ;
102-
103- impl < ' col > stringdex_internals:: Consumer for Consumer < ' col > {
104- type Err = FromUtf8Error ;
105-
106- fn consume ( & mut self , _id : u32 , cell : & [ u8 ] ) -> Result < ( ) , Self :: Err > {
107- self . 0 . push ( String :: from_utf8 ( cell. to_vec ( ) ) ?) ;
108- Ok ( ( ) )
109- }
110- }
101+ let mut consume = |_, cell : & [ u8 ] | {
102+ column. push ( String :: from_utf8 ( cell. to_vec ( ) ) ?) ;
103+ Ok :: < _ , FromUtf8Error > ( ( ) )
104+ } ;
111105
112106 stringdex_internals:: read_data_from_disk_column (
113107 root_path,
114108 column_name. as_bytes ( ) ,
115109 column_path. clone ( ) ,
116- & mut Consumer ( column ) ,
110+ & mut consume ,
117111 )
118112 . map_err ( |error| Error {
119113 file : column_path,
@@ -129,29 +123,20 @@ impl SerializedSearchIndex {
129123 let root_path = doc_root. join ( format ! ( "search.index/root{resource_suffix}.js" ) ) ;
130124 let column_path = doc_root. join ( format ! ( "search.index/{column_name}/" ) ) ;
131125
132- struct Consumer < ' col , T > ( & ' col mut Vec < Option < T > > ) ;
133-
134- impl < ' col , T > stringdex_internals:: Consumer for Consumer < ' col , T >
135- where
136- T : for < ' de > Deserialize < ' de > + ' static ,
137- {
138- type Err = serde_json:: Error ;
139-
140- fn consume ( & mut self , _id : u32 , cell : & [ u8 ] ) -> Result < ( ) , Self :: Err > {
141- if cell. is_empty ( ) {
142- self . 0 . push ( None ) ;
143- } else {
144- self . 0 . push ( Some ( serde_json:: from_slice ( cell) ?) ) ;
145- }
146- Ok ( ( ) )
126+ let mut consume = |_, cell : & [ u8 ] | {
127+ if cell. is_empty ( ) {
128+ column. push ( None ) ;
129+ } else {
130+ column. push ( Some ( serde_json:: from_slice ( cell) ?) ) ;
147131 }
148- }
132+ Ok :: < _ , serde_json:: Error > ( ( ) )
133+ } ;
149134
150135 stringdex_internals:: read_data_from_disk_column (
151136 root_path,
152137 column_name. as_bytes ( ) ,
153138 column_path. clone ( ) ,
154- & mut Consumer ( column ) ,
139+ & mut consume ,
155140 )
156141 . map_err ( |error| Error {
157142 file : column_path,
@@ -167,15 +152,13 @@ impl SerializedSearchIndex {
167152 let root_path = doc_root. join ( format ! ( "search.index/root{resource_suffix}.js" ) ) ;
168153 let column_path = doc_root. join ( format ! ( "search.index/{column_name}/" ) ) ;
169154
170- struct Consumer < ' col > ( & ' col mut Vec < Vec < Vec < u32 > > > ) ;
171-
172- impl < ' col > stringdex_internals:: Consumer for Consumer < ' col > {
173- type Err = io:: Error ;
174-
175- fn consume ( & mut self , _id : u32 , cell : & [ u8 ] ) -> Result < ( ) , Self :: Err > {
155+ fn consumer (
156+ column : & mut Vec < Vec < Vec < u32 > > > ,
157+ ) -> impl FnMut ( u32 , & [ u8 ] ) -> io:: Result < ( ) > {
158+ |_, cell| {
176159 let mut postings = Vec :: new ( ) ;
177160 encode:: read_postings_from_string ( & mut postings, cell) ;
178- self . 0 . push ( postings) ;
161+ column . push ( postings) ;
179162 Ok ( ( ) )
180163 }
181164 }
@@ -184,7 +167,7 @@ impl SerializedSearchIndex {
184167 root_path,
185168 column_name. as_bytes ( ) ,
186169 column_path. clone ( ) ,
187- & mut Consumer ( column) ,
170+ & mut consumer ( column) ,
188171 )
189172 . map_err ( |error| Error {
190173 file : column_path,
0 commit comments