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:
parent
2e0bbc091f
commit
f879bca21c
71 changed files with 411 additions and 436 deletions
|
|
@ -4,11 +4,11 @@ use std::mem::ManuallyDrop;
|
|||
use std::os::raw::c_void;
|
||||
use std::time::Instant;
|
||||
|
||||
use event::{Event, StartCause};
|
||||
use event_loop::ControlFlow;
|
||||
use crate::event::{Event, StartCause};
|
||||
use crate::event_loop::ControlFlow;
|
||||
|
||||
use platform_impl::platform::event_loop::{EventHandler, Never};
|
||||
use platform_impl::platform::ffi::{
|
||||
use crate::platform_impl::platform::event_loop::{EventHandler, Never};
|
||||
use crate::platform_impl::platform::ffi::{
|
||||
id,
|
||||
CFAbsoluteTimeGetCurrent,
|
||||
CFRelease,
|
||||
|
|
@ -39,10 +39,10 @@ enum AppStateImpl {
|
|||
Launching {
|
||||
queued_windows: Vec<id>,
|
||||
queued_events: Vec<Event<Never>>,
|
||||
queued_event_handler: Box<EventHandler>,
|
||||
queued_event_handler: Box<dyn EventHandler>,
|
||||
},
|
||||
ProcessingEvents {
|
||||
event_handler: Box<EventHandler>,
|
||||
event_handler: Box<dyn EventHandler>,
|
||||
active_control_flow: ControlFlow,
|
||||
},
|
||||
// special state to deal with reentrancy and prevent mutable aliasing.
|
||||
|
|
@ -50,11 +50,11 @@ enum AppStateImpl {
|
|||
queued_events: Vec<Event<Never>>,
|
||||
},
|
||||
Waiting {
|
||||
waiting_event_handler: Box<EventHandler>,
|
||||
waiting_event_handler: Box<dyn EventHandler>,
|
||||
start: Instant,
|
||||
},
|
||||
PollFinished {
|
||||
waiting_event_handler: Box<EventHandler>,
|
||||
waiting_event_handler: Box<dyn EventHandler>,
|
||||
},
|
||||
Terminated,
|
||||
}
|
||||
|
|
@ -134,7 +134,7 @@ impl AppState {
|
|||
}
|
||||
|
||||
// requires main thread
|
||||
pub unsafe fn will_launch(queued_event_handler: Box<EventHandler>) {
|
||||
pub unsafe fn will_launch(queued_event_handler: Box<dyn EventHandler>) {
|
||||
let mut this = AppState::get_mut();
|
||||
let (queued_windows, queued_events) = match &mut this.app_state {
|
||||
&mut AppStateImpl::NotLaunched {
|
||||
|
|
|
|||
|
|
@ -5,16 +5,16 @@ use std::fmt::{self, Debug, Formatter};
|
|||
use std::marker::PhantomData;
|
||||
use std::sync::mpsc::{self, Sender, Receiver};
|
||||
|
||||
use event::Event;
|
||||
use event_loop::{
|
||||
use crate::event::Event;
|
||||
use crate::event_loop::{
|
||||
ControlFlow,
|
||||
EventLoopWindowTarget as RootEventLoopWindowTarget,
|
||||
EventLoopClosed,
|
||||
};
|
||||
use platform::ios::Idiom;
|
||||
use crate::platform::ios::Idiom;
|
||||
|
||||
use platform_impl::platform::app_state::AppState;
|
||||
use platform_impl::platform::ffi::{
|
||||
use crate::platform_impl::platform::app_state::AppState;
|
||||
use crate::platform_impl::platform::ffi::{
|
||||
id,
|
||||
nil,
|
||||
CFIndex,
|
||||
|
|
@ -42,9 +42,9 @@ use platform_impl::platform::ffi::{
|
|||
UIApplicationMain,
|
||||
UIUserInterfaceIdiom,
|
||||
};
|
||||
use platform_impl::platform::monitor;
|
||||
use platform_impl::platform::MonitorHandle;
|
||||
use platform_impl::platform::view;
|
||||
use crate::platform_impl::platform::monitor;
|
||||
use crate::platform_impl::platform::MonitorHandle;
|
||||
use crate::platform_impl::platform::view;
|
||||
|
||||
pub struct EventLoopWindowTarget<T: 'static> {
|
||||
receiver: Receiver<T>,
|
||||
|
|
@ -281,7 +281,7 @@ struct EventLoopHandler<F, T: 'static> {
|
|||
}
|
||||
|
||||
impl<F, T: 'static> Debug for EventLoopHandler<F, T> {
|
||||
fn fmt(&self, formatter: &mut Formatter) -> fmt::Result {
|
||||
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
formatter.debug_struct("EventLoopHandler")
|
||||
.field("event_loop", &self.event_loop)
|
||||
.finish()
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ use std::os::raw::*;
|
|||
use objc::{Encode, Encoding};
|
||||
use objc::runtime::Object;
|
||||
|
||||
use platform::ios::{Idiom, ValidOrientations};
|
||||
use crate::platform::ios::{Idiom, ValidOrientations};
|
||||
|
||||
pub type id = *mut Object;
|
||||
pub const nil: id = 0 as id;
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ unsafe impl Sync for DeviceId {}
|
|||
pub enum OsError {}
|
||||
|
||||
impl fmt::Display for OsError {
|
||||
fn fmt(&self, _: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, _: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
_ => unreachable!()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,10 +4,10 @@ use std::{
|
|||
ops::{Deref, DerefMut},
|
||||
};
|
||||
|
||||
use dpi::{PhysicalPosition, PhysicalSize};
|
||||
use monitor::VideoMode;
|
||||
use crate::dpi::{PhysicalPosition, PhysicalSize};
|
||||
use crate::monitor::VideoMode;
|
||||
|
||||
use platform_impl::platform::ffi::{id, nil, CGFloat, CGRect, CGSize, NSInteger, NSUInteger};
|
||||
use crate::platform_impl::platform::ffi::{id, nil, CGFloat, CGRect, CGSize, NSInteger, NSUInteger};
|
||||
|
||||
pub struct Inner {
|
||||
uiscreen: id,
|
||||
|
|
@ -63,7 +63,7 @@ impl Drop for MonitorHandle {
|
|||
}
|
||||
|
||||
impl fmt::Debug for MonitorHandle {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
#[derive(Debug)]
|
||||
struct MonitorHandle {
|
||||
name: Option<String>,
|
||||
|
|
|
|||
|
|
@ -3,20 +3,20 @@ use std::collections::HashMap;
|
|||
use objc::declare::ClassDecl;
|
||||
use objc::runtime::{BOOL, Class, NO, Object, Sel, YES};
|
||||
|
||||
use event::{
|
||||
use crate::event::{
|
||||
DeviceId as RootDeviceId,
|
||||
Event,
|
||||
Touch,
|
||||
TouchPhase,
|
||||
WindowEvent
|
||||
};
|
||||
use platform::ios::MonitorHandleExtIOS;
|
||||
use window::{WindowAttributes, WindowId as RootWindowId};
|
||||
use crate::platform::ios::MonitorHandleExtIOS;
|
||||
use crate::window::{WindowAttributes, WindowId as RootWindowId};
|
||||
|
||||
use platform_impl::platform::app_state::AppState;
|
||||
use platform_impl::platform::DeviceId;
|
||||
use platform_impl::platform::event_loop;
|
||||
use platform_impl::platform::ffi::{
|
||||
use crate::platform_impl::platform::app_state::AppState;
|
||||
use crate::platform_impl::platform::DeviceId;
|
||||
use crate::platform_impl::platform::event_loop;
|
||||
use crate::platform_impl::platform::ffi::{
|
||||
id,
|
||||
nil,
|
||||
CGFloat,
|
||||
|
|
@ -25,7 +25,7 @@ use platform_impl::platform::ffi::{
|
|||
UIInterfaceOrientationMask,
|
||||
UITouchPhase,
|
||||
};
|
||||
use platform_impl::platform::window::{PlatformSpecificWindowBuilderAttributes};
|
||||
use crate::platform_impl::platform::window::{PlatformSpecificWindowBuilderAttributes};
|
||||
|
||||
// requires main thread
|
||||
unsafe fn get_view_class(root_view_class: &'static Class) -> &'static Class {
|
||||
|
|
|
|||
|
|
@ -5,16 +5,16 @@ use std::{
|
|||
|
||||
use objc::runtime::{Class, NO, Object, YES};
|
||||
|
||||
use dpi::{self, LogicalPosition, LogicalSize};
|
||||
use error::{ExternalError, NotSupportedError, OsError as RootOsError};
|
||||
use icon::Icon;
|
||||
use monitor::MonitorHandle as RootMonitorHandle;
|
||||
use platform::ios::{MonitorHandleExtIOS, ValidOrientations};
|
||||
use window::{
|
||||
use crate::dpi::{self, LogicalPosition, LogicalSize};
|
||||
use crate::error::{ExternalError, NotSupportedError, OsError as RootOsError};
|
||||
use crate::icon::Icon;
|
||||
use crate::monitor::MonitorHandle as RootMonitorHandle;
|
||||
use crate::platform::ios::{MonitorHandleExtIOS, ValidOrientations};
|
||||
use crate::window::{
|
||||
CursorIcon,
|
||||
WindowAttributes,
|
||||
};
|
||||
use platform_impl::{
|
||||
use crate::platform_impl::{
|
||||
platform::{
|
||||
app_state::AppState,
|
||||
event_loop,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue