@@ -4,7 +4,6 @@ use std::os::raw::c_void;
4
4
5
5
use self :: consts:: * ;
6
6
use plugin:: Plugin ;
7
- use std:: marker:: PhantomData ;
8
7
9
8
/// Constant values
10
9
#[ allow( missing_docs) ] // For obvious constants
@@ -405,7 +404,6 @@ pub struct Events {
405
404
406
405
impl Events {
407
406
#[ inline]
408
- #[ allow( dead_code) ]
409
407
pub ( crate ) fn events_raw ( & self ) -> & [ * const Event ] {
410
408
use std:: slice;
411
409
unsafe {
@@ -453,37 +451,9 @@ impl Events {
453
451
/// # }
454
452
/// ```
455
453
#[ inline]
456
- pub fn events ( & self ) -> EventIterator {
457
- let ptr = self . events . as_ptr ( ) as * const * const Event ;
458
- EventIterator {
459
- current : ptr,
460
- end : unsafe { ptr. offset ( self . num_events as isize ) } ,
461
- _marker : PhantomData ,
462
- }
463
- }
464
- }
465
-
466
- /// An iterator over events, returned by `api::Events::events`
467
- pub struct EventIterator < ' a > {
468
- current : * const * const Event ,
469
- end : * const * const Event ,
470
- _marker : PhantomData < & ' a Event > ,
471
- }
472
-
473
- impl < ' a > Iterator for EventIterator < ' a > {
474
- type Item = :: event:: Event < ' a > ;
475
-
476
- fn next ( & mut self ) -> Option < Self :: Item > {
477
- if self . current == self . end {
478
- None
479
- } else {
480
- let event = unsafe {
481
- let e = * * self . current ;
482
- self . current = self . current . offset ( 1 ) ;
483
- e
484
- } ;
485
- Some ( event. into ( ) )
486
- }
454
+ #[ allow( clippy:: needless_lifetimes) ]
455
+ pub fn events < ' a > ( & ' a self ) -> impl Iterator < Item = :: event:: Event < ' a > > {
456
+ self . events_raw ( ) . iter ( ) . map ( |ptr| unsafe { * * ptr } . into ( ) )
487
457
}
488
458
}
489
459
0 commit comments