pub fn peek_events<B>(&self, max_amount: u32) -> B
    where B: FromIterator<Event>
    {
        unsafe {
            let mut events = Vec::with_capacity(max_amount as usize);

            let result = {
                let events_ptr = events.as_mut_ptr();

                sys::SDL_PeepEvents(
                    events_ptr,
                    max_amount as c_int,
                    sys::SDL_eventaction::SDL_PEEKEVENT,
                    sys::SDL_EventType::SDL_FIRSTEVENT as u32,
                    sys::SDL_EventType::SDL_LASTEVENT as u32
                )
            };

            if result < 0 {
                // The only error possible is "Couldn't lock event queue"
                panic!(get_error());
            } else {
                events.set_len(result as usize);

                events.into_iter().map(|event_raw| {
                    Event::from_ll(event_raw)
                }).collect()
            }
        }
    }
/// Reads the events at the front of the event queue, until the maximum amount
/// of events is read.
///
/// The events will _not_ be removed from the queue.
///
/// # Example
/// ```no_run
/// use sdl2::event::Event;
///
/// let sdl_context = sdl2::init().unwrap();
/// let event_subsystem = sdl_context.event().unwrap();
///
/// // Read up to 1024 events
/// let events: Vec<Event> = event_subsystem.peek_events(1024);
///
/// // Print each one
/// for event in events {
///     println!("{:?}", event);
/// }
/// ```
Reads the events at the front of the event queue, until the maximum amount
of events is read.

The events will _not_ be removed from the queue.
Reads the events at the front of the event queue until the maximum amount of events is read . The events will _not_ be removed from the queue .
pub fn peek_events<B>(&self, max_amount: u32) -> B
    where B: FromIterator<Event>
    {
        unsafe {
            let mut events = Vec::with_capacity(max_amount as usize);
            let result = {
                let events_ptr = events.as_mut_ptr();
                sys::SDL_PeepEvents(
                    events_ptr,
                    max_amount as c_int,
                    sys::SDL_eventaction::SDL_PEEKEVENT,
                    sys::SDL_EventType::SDL_FIRSTEVENT as u32,
                    sys::SDL_EventType::SDL_LASTEVENT as u32
                )
            };
            if result < 0 {
                // The only error possible is "Couldn't lock event queue"
                panic!(get_error());
            } else {
                events.set_len(result as usize);
                events.into_iter().map(|event_raw| {
                    Event::from_ll(event_raw)
                }).collect()
            }
        }
    }
pub fn peek_events < B > ( & self , max_amount : u32 ) -> B where B : FromIterator < Event > { unsafe { let mut events = Vec :: with_capacity ( max_amount as usize ) ; let result = { let events_ptr = events . as_mut_ptr ( ) ; sys :: SDL_PeepEvents ( events_ptr , max_amount as c_int , sys :: SDL_eventaction :: SDL_PEEKEVENT , sys :: SDL_EventType :: SDL_FIRSTEVENT as u32 , sys :: SDL_EventType :: SDL_LASTEVENT as u32 ) } ; if result < 0 { // The only error possible is "Couldn't lock event queue" panic ! ( get_error ( ) ) ; } else { events . set_len ( result as usize ) ; events . into_iter ( ) . map ( | event_raw | { Event :: from_ll ( event_raw ) } ) . collect ( ) } } }
Reads the events at the front of the event queue, until the maximum amount
of events is read.
Reads the events at the front of the event queue until the maximum amount of events is read .
&self
max_amount
u32
&self
max_amount
u32
example
```no_run
use sdl2::event::Event.

let sdl_context = sdl2::init().unwrap();
let event_subsystem = sdl_context.event().unwrap().

Read up to 1024 events
let events: Vec = event_subsystem.peek_events(1024).

Print each one
for event in events {
println!("{:?}", event);
}
```
` ` ` no_run use sdl2 :: event :: Event . let sdl_context = sdl2 :: init () . unwrap () ; let event_subsystem = sdl_context . event () . unwrap () . Read up to 1024 events let events : Vec = event_subsystem . peek_events ( 1024 ) . Print each one for event in events { println! ( " { : ? } " event ) ; } ` ` `