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

@ -14,17 +14,17 @@ use winapi::um::oleidl::{DROPEFFECT_COPY, DROPEFFECT_NONE, IDropTarget, IDropTar
use winapi::um::winnt::HRESULT;
use winapi::um::{shellapi, unknwnbase};
use platform_impl::platform::WindowId;
use crate::platform_impl::platform::WindowId;
use event::Event;
use window::WindowId as SuperWindowId;
use crate::event::Event;
use crate::window::WindowId as SuperWindowId;
#[repr(C)]
pub struct FileDropHandlerData {
pub interface: IDropTarget,
refcount: AtomicUsize,
window: HWND,
send_event: Box<Fn(Event<()>)>,
send_event: Box<dyn Fn(Event<()>)>,
cursor_effect: DWORD,
hovered_is_valid: bool, // If the currently hovered item is not valid there must not be any `HoveredFileCancelled` emitted
}
@ -35,7 +35,7 @@ pub struct FileDropHandler {
#[allow(non_snake_case)]
impl FileDropHandler {
pub fn new(window: HWND, send_event: Box<Fn(Event<()>)>) -> FileDropHandler {
pub fn new(window: HWND, send_event: Box<dyn Fn(Event<()>)>) -> FileDropHandler {
let data = Box::new(FileDropHandlerData {
interface: IDropTarget {
lpVtbl: &DROP_TARGET_VTBL as *const IDropTargetVtbl,
@ -85,7 +85,7 @@ impl FileDropHandler {
_pt: *const POINTL,
pdwEffect: *mut DWORD,
) -> HRESULT {
use event::WindowEvent::HoveredFile;
use crate::event::WindowEvent::HoveredFile;
let drop_handler = Self::from_interface(this);
let hdrop = Self::iterate_filenames(pDataObj, |filename| {
drop_handler.send_event(Event::WindowEvent {
@ -117,7 +117,7 @@ impl FileDropHandler {
}
pub unsafe extern "system" fn DragLeave(this: *mut IDropTarget) -> HRESULT {
use event::WindowEvent::HoveredFileCancelled;
use crate::event::WindowEvent::HoveredFileCancelled;
let drop_handler = Self::from_interface(this);
if drop_handler.hovered_is_valid {
drop_handler.send_event(Event::WindowEvent {
@ -136,7 +136,7 @@ impl FileDropHandler {
_pt: *const POINTL,
_pdwEffect: *mut DWORD,
) -> HRESULT {
use event::WindowEvent::DroppedFile;
use crate::event::WindowEvent::DroppedFile;
let drop_handler = Self::from_interface(this);
let hdrop = Self::iterate_filenames(pDataObj, |filename| {
drop_handler.send_event(Event::WindowEvent {