Skip to content

Commit

Permalink
Run rustfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
Teddy DeRego committed Sep 4, 2020
1 parent f2ea6ae commit ea2238a
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 31 deletions.
13 changes: 9 additions & 4 deletions futures/src/lib.rs
Expand Up @@ -14,10 +14,15 @@ mod runtime;
pub mod executor;
pub mod subscription;

#[cfg(any(
feature = "tokio", feature = "async-std", target_arch = "wasm32"
))]
#[cfg_attr(docsrs, doc(cfg(any(feature = "tokio", feature = "async-std", target_arch = "wasm32"))))]
#[cfg(any(feature = "tokio", feature = "async-std", target_arch = "wasm32"))]
#[cfg_attr(
docsrs,
doc(cfg(any(
feature = "tokio",
feature = "async-std",
target_arch = "wasm32"
)))
)]
pub mod time;

pub use command::Command;
Expand Down
3 changes: 1 addition & 2 deletions futures/src/runtime.rs
Expand Up @@ -131,8 +131,7 @@ where
Hasher: std::hash::Hasher + Default,
Event: Send + Clone + 'static,
Executor: self::Executor,
Sender:
Sink<Message, Error = mpsc::SendError> + Unpin + Clone + 'static,
Sender: Sink<Message, Error = mpsc::SendError> + Unpin + Clone + 'static,
Message: 'static,
{
/// Creates a new empty [`Runtime`].
Expand Down
6 changes: 2 additions & 4 deletions futures/src/subscription/tracker.rs
Expand Up @@ -192,10 +192,8 @@ where
) -> Vec<BoxFuture<()>>
where
Message: 'static,
Receiver: 'static
+ Sink<Message, Error = mpsc::SendError>
+ Unpin
+ Clone,
Receiver:
'static + Sink<Message, Error = mpsc::SendError> + Unpin + Clone,
{
use futures::{future::FutureExt, stream::StreamExt};

Expand Down
8 changes: 6 additions & 2 deletions futures/src/time.rs
Expand Up @@ -56,7 +56,11 @@ where
}
}

#[cfg(all(feature = "tokio", not(feature = "async-std"), not(target_arch = "wasm32")))]
#[cfg(all(
feature = "tokio",
not(feature = "async-std"),
not(target_arch = "wasm32")
))]
impl<H, E> subscription::Recipe<H, E> for Every
where
H: std::hash::Hasher,
Expand Down Expand Up @@ -106,7 +110,7 @@ where

Box::pin(
wasm_timer::Interval::new(self.0)
.map(|_| wasm_timer::Instant::now())
.map(|_| wasm_timer::Instant::now()),
)
}
}
6 changes: 5 additions & 1 deletion glow/src/triangle.rs
Expand Up @@ -164,7 +164,11 @@ impl Pipeline {
{
// XXX allocating a big ol' array for every mesh on every draw because WebGL
// doesn't support `draw_elements_base_vertex`.
let indices: Vec<_> = buffers.indices.iter().map(|x| *x + last_vertex as u32).collect();
let indices: Vec<_> = buffers
.indices
.iter()
.map(|x| *x + last_vertex as u32)
.collect();
gl.buffer_sub_data_u8_slice(
glow::ELEMENT_ARRAY_BUFFER,
(last_index * std::mem::size_of::<u32>()) as i32,
Expand Down
12 changes: 7 additions & 5 deletions src/lib.rs
Expand Up @@ -190,20 +190,22 @@ pub mod settings;
pub mod widget;
pub mod window;

#[cfg(all(
any(feature = "tokio", feature = "async-std", target_arch = "wasm32"),
))]
#[cfg(all(any(
feature = "tokio",
feature = "async-std",
target_arch = "wasm32"
),))]
#[cfg_attr(docsrs, doc(cfg(any(feature = "tokio", feature = "async-std"))))]
pub mod time;

#[cfg(all(target_arch = "wasm32", not(feature = "web")))]
use iced_web_winit as runtime;
#[cfg(all(
not(target_arch = "wasm32"),
not(feature = "glow"),
feature = "wgpu"
))]
use iced_winit as runtime;
#[cfg(all(target_arch = "wasm32", not(feature = "web")))]
use iced_web_winit as runtime;

#[cfg(all(not(target_arch = "wasm32"), feature = "glow"))]
use iced_glutin as runtime;
Expand Down
27 changes: 14 additions & 13 deletions web_winit/src/application.rs
Expand Up @@ -25,7 +25,7 @@ pub fn run<A, E, C>(
use winit::{
event,
event_loop::{ControlFlow, EventLoop},
platform::web::WindowExtWebSys,
platform::web::WindowExtWebSys,
};

let mut debug = Debug::new();
Expand Down Expand Up @@ -72,19 +72,23 @@ pub fn run<A, E, C>(
canvas.set_width(width);
canvas.set_height(height);

let _ = body.append_child(&canvas)
let _ = body
.append_child(&canvas)
.expect("Append canvas to HTML body");

let onresize_callback = {
wasm_bindgen::closure::Closure::wrap(Box::new(move || {
let window = web_sys::window().unwrap();

let width = window.inner_width().unwrap().as_f64().unwrap() as u32;
let height = window.inner_height().unwrap().as_f64().unwrap() as u32;
let width =
window.inner_width().unwrap().as_f64().unwrap() as u32;
let height =
window.inner_height().unwrap().as_f64().unwrap() as u32;

canvas.set_width(width);
canvas.set_height(height);
}) as Box<dyn FnMut()>)
})
as Box<dyn FnMut()>)
};
window.set_onresize(Some(onresize_callback.as_ref().unchecked_ref()));
onresize_callback.forget();
Expand All @@ -103,11 +107,8 @@ pub fn run<A, E, C>(
let mut resized = false;

#[allow(unsafe_code)]
let (mut compositor, mut renderer) = unsafe {
C::new(compositor_settings, |address| {
std::ptr::null()
})
};
let (mut compositor, mut renderer) =
unsafe { C::new(compositor_settings, |address| std::ptr::null()) };

let mut state = program::State::new(
application,
Expand Down Expand Up @@ -231,9 +232,9 @@ pub fn run<A, E, C>(
debug.render_finished();

if new_mouse_interaction != mouse_interaction {
window.set_cursor_icon(
conversion::mouse_interaction(new_mouse_interaction),
);
window.set_cursor_icon(conversion::mouse_interaction(
new_mouse_interaction,
));

mouse_interaction = new_mouse_interaction;
}
Expand Down

0 comments on commit ea2238a

Please sign in to comment.