File tree Expand file tree Collapse file tree 1 file changed +11
-8
lines changed Expand file tree Collapse file tree 1 file changed +11
-8
lines changed Original file line number Diff line number Diff line change @@ -433,10 +433,12 @@ struct ListPart<'a> {
433433}
434434impl < ' a > From < & ' a ngx_list_part_t > for ListPart < ' a > {
435435 fn from ( raw : & ' a ngx_list_part_t ) -> Self {
436- Self {
437- raw,
438- arr : unsafe { from_raw_parts ( raw. elts . cast :: < ngx_table_elt_t > ( ) , raw. nelts ) } ,
439- }
436+ let arr = if let Some ( elts) = unsafe { raw. elts . cast :: < ngx_table_elt_t > ( ) . as_ref ( ) } {
437+ unsafe { from_raw_parts ( elts, raw. nelts ) }
438+ } else {
439+ & [ ]
440+ } ;
441+ Self { raw, arr }
440442 }
441443}
442444
@@ -461,18 +463,19 @@ impl<'a> Iterator for NgxListIterator<'a> {
461463 type Item = ( & ' a str , & ' a str ) ;
462464
463465 fn next ( & mut self ) -> Option < Self :: Item > {
464- let part = self . part . as_ref ( ) ?;
465- let header = & part. arr [ self . i ] ;
466- self . i += 1 ;
466+ let part = self . part . as_mut ( ) ?;
467467 if self . i >= part. arr . len ( ) {
468468 if let Some ( next_part_raw) = unsafe { part. raw . next . as_ref ( ) } {
469469 // loop back
470- self . part = Some ( next_part_raw. into ( ) ) ;
470+ * part = next_part_raw. into ( ) ;
471471 self . i = 0 ;
472472 } else {
473473 self . part = None ;
474+ return None ;
474475 }
475476 }
477+ let header = & part. arr [ self . i ] ;
478+ self . i += 1 ;
476479 Some ( ( header. key . to_str ( ) , header. value . to_str ( ) ) )
477480 }
478481}
You can’t perform that action at this time.
0 commit comments