Migrate to 2018 edition. (#924)

* Migrate to 2018 edition.

* Use impl Iterator at one site.

* Fix more rust 2018 idioms.
This commit is contained in:
CrLF0710 2019-06-18 02:27:00 +08:00 committed by Osspial
parent 2e0bbc091f
commit f879bca21c
71 changed files with 411 additions and 436 deletions

View file

@ -25,12 +25,12 @@ use std::sync::{Arc, mpsc, Weak, Mutex};
use libc::{self, setlocale, LC_CTYPE};
use error::OsError as RootOsError;
use event_loop::{ControlFlow, EventLoopClosed, EventLoopWindowTarget as RootELW};
use event::{WindowEvent, Event};
use platform_impl::PlatformSpecificWindowBuilderAttributes;
use platform_impl::platform::sticky_exit_callback;
use window::{WindowAttributes};
use crate::error::OsError as RootOsError;
use crate::event_loop::{ControlFlow, EventLoopClosed, EventLoopWindowTarget as RootELW};
use crate::event::{WindowEvent, Event};
use crate::platform_impl::PlatformSpecificWindowBuilderAttributes;
use crate::platform_impl::platform::sticky_exit_callback;
use crate::window::{WindowAttributes};
use self::dnd::{Dnd, DndState};
use self::ime::{ImeReceiver, ImeSender, ImeCreationError, Ime};
use self::event_processor::EventProcessor;
@ -243,7 +243,7 @@ impl<T: 'static> EventLoop<T> {
let mut guard = self.pending_user_events.borrow_mut();
for evt in guard.drain(..) {
sticky_exit_callback(
::event::Event::UserEvent(evt),
crate::event::Event::UserEvent(evt),
&self.target,
&mut control_flow,
&mut callback
@ -256,7 +256,7 @@ impl<T: 'static> EventLoop<T> {
for wid in guard.drain() {
sticky_exit_callback(
Event::WindowEvent {
window_id: ::window::WindowId(super::WindowId::X(wid)),
window_id: crate::window::WindowId(super::WindowId::X(wid)),
event: WindowEvent::RedrawRequested
},
&self.target,
@ -268,7 +268,7 @@ impl<T: 'static> EventLoop<T> {
// send Events cleared
{
sticky_exit_callback(
::event::Event::EventsCleared,
crate::event::Event::EventsCleared,
&self.target,
&mut control_flow,
&mut callback
@ -283,12 +283,12 @@ impl<T: 'static> EventLoop<T> {
ControlFlow::Poll => {
// non-blocking dispatch
self.inner_loop.dispatch(Some(::std::time::Duration::from_millis(0)), &mut ()).unwrap();
callback(::event::Event::NewEvents(::event::StartCause::Poll), &self.target, &mut control_flow);
callback(crate::event::Event::NewEvents(crate::event::StartCause::Poll), &self.target, &mut control_flow);
},
ControlFlow::Wait => {
self.inner_loop.dispatch(None, &mut ()).unwrap();
callback(
::event::Event::NewEvents(::event::StartCause::WaitCancelled {
crate::event::Event::NewEvents(crate::event::StartCause::WaitCancelled {
start: ::std::time::Instant::now(),
requested_resume: None
}),
@ -308,7 +308,7 @@ impl<T: 'static> EventLoop<T> {
let now = std::time::Instant::now();
if now < deadline {
callback(
::event::Event::NewEvents(::event::StartCause::WaitCancelled {
crate::event::Event::NewEvents(crate::event::StartCause::WaitCancelled {
start,
requested_resume: Some(deadline)
}),
@ -317,7 +317,7 @@ impl<T: 'static> EventLoop<T> {
);
} else {
callback(
::event::Event::NewEvents(::event::StartCause::ResumeTimeReached {
crate::event::Event::NewEvents(crate::event::StartCause::ResumeTimeReached {
start,
requested_resume: deadline
}),
@ -329,7 +329,7 @@ impl<T: 'static> EventLoop<T> {
}
}
callback(::event::Event::LoopDestroyed, &self.target, &mut control_flow);
callback(crate::event::Event::LoopDestroyed, &self.target, &mut control_flow);
}
pub fn run<F>(mut self, callback: F) -> !
@ -485,8 +485,8 @@ struct XExtension {
first_error_id: c_int,
}
fn mkwid(w: ffi::Window) -> ::window::WindowId { ::window::WindowId(::platform_impl::WindowId::X(WindowId(w))) }
fn mkdid(w: c_int) -> ::event::DeviceId { ::event::DeviceId(::platform_impl::DeviceId::X(DeviceId(w))) }
fn mkwid(w: ffi::Window) -> crate::window::WindowId { crate::window::WindowId(crate::platform_impl::WindowId::X(WindowId(w))) }
fn mkdid(w: c_int) -> crate::event::DeviceId { crate::event::DeviceId(crate::platform_impl::DeviceId::X(DeviceId(w))) }
#[derive(Debug)]
struct Device {