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
|
|
@ -3,8 +3,8 @@ use std::collections::VecDeque;
|
|||
use cocoa::{appkit::{self, NSEvent}, base::id};
|
||||
use objc::{declare::ClassDecl, runtime::{Class, Object, Sel}};
|
||||
|
||||
use event::{DeviceEvent, Event};
|
||||
use platform_impl::platform::{app_state::AppState, DEVICE_ID, util};
|
||||
use crate::event::{DeviceEvent, Event};
|
||||
use crate::platform_impl::platform::{app_state::AppState, DEVICE_ID, util};
|
||||
|
||||
pub struct AppClass(pub *const Class);
|
||||
unsafe impl Send for AppClass {}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use cocoa::base::id;
|
||||
use objc::{runtime::{Class, Object, Sel, BOOL, YES}, declare::ClassDecl};
|
||||
|
||||
use platform_impl::platform::app_state::AppState;
|
||||
use crate::platform_impl::platform::app_state::AppState;
|
||||
|
||||
pub struct AppDelegateClass(pub *const Class);
|
||||
unsafe impl Send for AppDelegateClass {}
|
||||
|
|
|
|||
|
|
@ -6,12 +6,12 @@ use std::{
|
|||
|
||||
use cocoa::{appkit::NSApp, base::nil};
|
||||
|
||||
use {
|
||||
use crate::{
|
||||
event::{Event, StartCause, WindowEvent},
|
||||
event_loop::{ControlFlow, EventLoopWindowTarget as RootWindowTarget},
|
||||
window::WindowId,
|
||||
};
|
||||
use platform_impl::platform::{observer::EventLoopWaker, util::Never};
|
||||
use crate::platform_impl::platform::{observer::EventLoopWaker, util::Never};
|
||||
|
||||
lazy_static! {
|
||||
static ref HANDLER: Handler = Default::default();
|
||||
|
|
@ -38,7 +38,7 @@ struct EventLoopHandler<F, T: 'static> {
|
|||
}
|
||||
|
||||
impl<F, T> 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("window_target", &self.window_target)
|
||||
.finish()
|
||||
|
|
|
|||
|
|
@ -2,11 +2,11 @@ use std::os::raw::c_ushort;
|
|||
|
||||
use cocoa::{appkit::{NSEvent, NSEventModifierFlags}, base::id};
|
||||
|
||||
use event::{
|
||||
use crate::event::{
|
||||
ElementState, KeyboardInput,
|
||||
ModifiersState, VirtualKeyCode, WindowEvent,
|
||||
};
|
||||
use platform_impl::platform::DEVICE_ID;
|
||||
use crate::platform_impl::platform::DEVICE_ID;
|
||||
|
||||
pub fn char_to_keycode(c: char) -> Option<VirtualKeyCode> {
|
||||
// We only translate keys that are affected by keyboard layout.
|
||||
|
|
|
|||
|
|
@ -4,11 +4,11 @@ use std::{
|
|||
|
||||
use cocoa::{appkit::NSApp, base::{id, nil}, foundation::NSAutoreleasePool};
|
||||
|
||||
use {
|
||||
use crate::{
|
||||
event::Event,
|
||||
event_loop::{ControlFlow, EventLoopClosed, EventLoopWindowTarget as RootWindowTarget},
|
||||
};
|
||||
use platform_impl::platform::{
|
||||
use crate::platform_impl::platform::{
|
||||
app::APP_CLASS, app_delegate::APP_DELEGATE_CLASS,
|
||||
app_state::AppState, monitor::{self, MonitorHandle},
|
||||
observer::*, util::IdRef,
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ mod window_delegate;
|
|||
|
||||
use std::{fmt, ops::Deref, sync::Arc};
|
||||
|
||||
use {
|
||||
use crate::{
|
||||
event::DeviceId as RootDeviceId, window::WindowAttributes,
|
||||
error::OsError as RootOsError,
|
||||
};
|
||||
|
|
@ -74,7 +74,7 @@ impl Window {
|
|||
}
|
||||
|
||||
impl fmt::Display for OsError {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
OsError::CGError(e) => f.pad(&format!("CGError {}", e)),
|
||||
OsError::CreationError(e) => f.pad(e),
|
||||
|
|
|
|||
|
|
@ -11,9 +11,9 @@ use core_video_sys::{
|
|||
CVDisplayLinkGetNominalOutputVideoRefreshPeriod, CVDisplayLinkRelease,
|
||||
};
|
||||
|
||||
use dpi::{PhysicalPosition, PhysicalSize};
|
||||
use monitor::VideoMode;
|
||||
use platform_impl::platform::util::IdRef;
|
||||
use crate::dpi::{PhysicalPosition, PhysicalSize};
|
||||
use crate::monitor::VideoMode;
|
||||
use crate::platform_impl::platform::util::IdRef;
|
||||
|
||||
#[derive(Clone, PartialEq)]
|
||||
pub struct MonitorHandle(CGDirectDisplayID);
|
||||
|
|
@ -35,7 +35,7 @@ pub fn primary_monitor() -> MonitorHandle {
|
|||
}
|
||||
|
||||
impl fmt::Debug for MonitorHandle {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
// TODO: Do this using the proper fmt API
|
||||
#[derive(Debug)]
|
||||
struct MonitorHandle {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use std::{self, ptr, os::raw::*, time::Instant};
|
||||
|
||||
use platform_impl::platform::app_state::AppState;
|
||||
use crate::platform_impl::platform::app_state::AppState;
|
||||
|
||||
#[link(name = "CoreFoundation", kind = "framework")]
|
||||
extern {
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@ use cocoa::{
|
|||
};
|
||||
use dispatch::ffi::{dispatch_async_f, dispatch_get_main_queue, dispatch_sync_f};
|
||||
|
||||
use dpi::LogicalSize;
|
||||
use platform_impl::platform::{ffi, window::SharedState};
|
||||
use crate::dpi::LogicalSize;
|
||||
use crate::platform_impl::platform::{ffi, window::SharedState};
|
||||
|
||||
unsafe fn set_style_mask(ns_window: id, ns_view: id, mask: NSWindowStyleMask) {
|
||||
ns_window.setStyleMask_(mask);
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use cocoa::{
|
|||
};
|
||||
use objc::runtime::Sel;
|
||||
|
||||
use window::CursorIcon;
|
||||
use crate::window::CursorIcon;
|
||||
|
||||
pub enum Cursor {
|
||||
Native(&'static str),
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
mod async;
|
||||
mod r#async;
|
||||
mod cursor;
|
||||
|
||||
pub use self::{async::*, cursor::*};
|
||||
pub use self::{r#async::*, cursor::*};
|
||||
|
||||
use std::ops::Deref;
|
||||
use std::ops::BitAnd;
|
||||
|
|
@ -14,7 +14,7 @@ use cocoa::{
|
|||
use core_graphics::display::CGDisplay;
|
||||
use objc::runtime::{BOOL, Class, Object, Sel, YES};
|
||||
|
||||
use platform_impl::platform::ffi;
|
||||
use crate::platform_impl::platform::ffi;
|
||||
|
||||
// Replace with `!` once stable
|
||||
#[derive(Debug)]
|
||||
|
|
|
|||
|
|
@ -9,14 +9,14 @@ use cocoa::{
|
|||
};
|
||||
use objc::{declare::ClassDecl, runtime::{BOOL, Class, NO, Object, Protocol, Sel, YES}};
|
||||
|
||||
use {
|
||||
use crate::{
|
||||
event::{
|
||||
DeviceEvent, ElementState, Event, KeyboardInput, MouseButton,
|
||||
MouseScrollDelta, TouchPhase, VirtualKeyCode, WindowEvent,
|
||||
},
|
||||
window::WindowId,
|
||||
};
|
||||
use platform_impl::platform::{
|
||||
use crate::platform_impl::platform::{
|
||||
app_state::AppState, DEVICE_ID,
|
||||
event::{check_function_keys, event_mods, modifier_event, char_to_keycode, get_scancode, scancode_to_keycode},
|
||||
util::{self, IdRef}, ffi::*, window::get_window_id,
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ use cocoa::{
|
|||
use core_graphics::display::CGDisplay;
|
||||
use objc::{runtime::{Class, Object, Sel, BOOL, YES, NO}, declare::ClassDecl};
|
||||
|
||||
use {
|
||||
use crate::{
|
||||
dpi::{LogicalPosition, LogicalSize}, icon::Icon,
|
||||
error::{ExternalError, NotSupportedError, OsError as RootOsError},
|
||||
monitor::MonitorHandle as RootMonitorHandle,
|
||||
|
|
@ -23,8 +23,8 @@ use {
|
|||
CursorIcon, WindowAttributes, WindowId as RootWindowId,
|
||||
},
|
||||
};
|
||||
use platform::macos::{ActivationPolicy, WindowExtMacOS};
|
||||
use platform_impl::platform::{
|
||||
use crate::platform::macos::{ActivationPolicy, WindowExtMacOS};
|
||||
use crate::platform_impl::platform::{
|
||||
OsError,
|
||||
app_state::AppState, ffi, monitor::{self, MonitorHandle},
|
||||
util::{self, IdRef}, view::{self, new_view},
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@ use cocoa::{
|
|||
};
|
||||
use objc::{runtime::{Class, Object, Sel, BOOL, YES, NO}, declare::ClassDecl};
|
||||
|
||||
use {dpi::LogicalSize, event::{Event, WindowEvent}, window::WindowId};
|
||||
use platform_impl::platform::{
|
||||
use crate::{dpi::LogicalSize, event::{Event, WindowEvent}, window::WindowId};
|
||||
use crate::platform_impl::platform::{
|
||||
app_state::AppState, util::{self, IdRef},
|
||||
window::{get_window_id, UnownedWindow},
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue