Skip to content

Commit 8374341

Browse files
committed
Reformat code with cargo fmt
1 parent edb0cca commit 8374341

File tree

17 files changed

+101
-118
lines changed

17 files changed

+101
-118
lines changed

android-example/rust/src/lib.rs

+7-9
Original file line numberDiff line numberDiff line change
@@ -167,14 +167,12 @@ impl ResourceLoader for JavaResourceLoader {
167167

168168
let loader = self.loader.as_obj();
169169
let mut env = self.vm.get_env().unwrap();
170-
match env
171-
.call_method(
172-
loader,
173-
"slurp",
174-
"(Ljava/lang/String;)Ljava/nio/ByteBuffer;",
175-
&[JValue::Object(&env.new_string(filename).unwrap())],
176-
)
177-
{
170+
match env.call_method(
171+
loader,
172+
"slurp",
173+
"(Ljava/lang/String;)Ljava/nio/ByteBuffer;",
174+
&[JValue::Object(&env.new_string(filename).unwrap())],
175+
) {
178176
Ok(JValueGen::Object(object)) => {
179177
let byte_buffer = JByteBuffer::from(object);
180178
unsafe {
@@ -184,7 +182,7 @@ impl ResourceLoader for JavaResourceLoader {
184182
);
185183
dest.extend_from_slice(slice);
186184
}
187-
},
185+
}
188186
_ => panic!("Unexpected return value!"),
189187
}
190188
}

surfman/examples/chaos_game.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use euclid::default::Point2D;
66
use rand::{self, Rng};
77
use surfman::{SurfaceAccess, SurfaceType};
88
use winit::dpi::PhysicalSize;
9-
use winit::event::{DeviceEvent, Event, WindowEvent, KeyboardInput, VirtualKeyCode};
9+
use winit::event::{DeviceEvent, Event, KeyboardInput, VirtualKeyCode, WindowEvent};
1010
use winit::event_loop::{ControlFlow, EventLoop};
1111
use winit::window::WindowBuilder;
1212

surfman/examples/threads.rs

+43-29
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use winit::{
2121
dpi::PhysicalSize,
2222
event::{DeviceEvent, Event, WindowEvent},
2323
event_loop::{ControlFlow, EventLoop},
24-
window::WindowBuilder
24+
window::WindowBuilder,
2525
};
2626

2727
#[cfg(feature = "sm-raw-window-handle-05")]
@@ -91,24 +91,27 @@ static BACKGROUND_COLOR: [f32; 4] = [
9191
];
9292

9393
#[cfg(feature = "sm-raw-window-handle-05")]
94-
fn make_connection(window: &winit::window::Window) -> surfman::Connection
95-
{
94+
fn make_connection(window: &winit::window::Window) -> surfman::Connection {
9695
let raw_display_handle = window.raw_display_handle();
9796
let connection = Connection::from_raw_display_handle(raw_display_handle).unwrap();
9897
connection
9998
}
10099

101100
#[cfg(not(feature = "sm-raw-window-handle-05"))]
102-
fn make_connection(window: &winit::window::Window) -> surfman::Connection
103-
{
104-
let display_handle = window.display_handle().expect("failed to get display handle from window");
101+
fn make_connection(window: &winit::window::Window) -> surfman::Connection {
102+
let display_handle = window
103+
.display_handle()
104+
.expect("failed to get display handle from window");
105105
let connection = Connection::from_display_handle(display_handle).unwrap();
106106
connection
107107
}
108108

109109
#[cfg(feature = "sm-raw-window-handle-05")]
110-
fn make_native_widget(window: &winit::window::Window, connection: &surfman::Connection, window_size: Size2D<i32>) -> surfman::NativeWidget
111-
{
110+
fn make_native_widget(
111+
window: &winit::window::Window,
112+
connection: &surfman::Connection,
113+
window_size: Size2D<i32>,
114+
) -> surfman::NativeWidget {
112115
let raw_window_handle = window.raw_window_handle();
113116
let native_widget = connection
114117
.create_native_widget_from_raw_window_handle(raw_window_handle, window_size)
@@ -117,9 +120,14 @@ fn make_native_widget(window: &winit::window::Window, connection: &surfman::Conn
117120
}
118121

119122
#[cfg(not(feature = "sm-raw-window-handle-05"))]
120-
fn make_native_widget(window: &winit::window::Window, connection: &surfman::Connection, window_size: Size2D<i32>) -> surfman::NativeWidget
121-
{
122-
let raw_window_handle = window.window_handle().expect("couldn't get window handle from window");
123+
fn make_native_widget(
124+
window: &winit::window::Window,
125+
connection: &surfman::Connection,
126+
window_size: Size2D<i32>,
127+
) -> surfman::NativeWidget {
128+
let raw_window_handle = window
129+
.window_handle()
130+
.expect("couldn't get window handle from window");
123131
let native_widget = connection
124132
.create_native_widget_from_window_handle(raw_window_handle, window_size)
125133
.unwrap();
@@ -128,7 +136,10 @@ fn make_native_widget(window: &winit::window::Window, connection: &surfman::Conn
128136

129137
#[cfg(not(target_os = "android"))]
130138
fn main() {
131-
use winit::{event::RawKeyEvent, keyboard::{KeyCode, PhysicalKey}};
139+
use winit::{
140+
event::RawKeyEvent,
141+
keyboard::{KeyCode, PhysicalKey},
142+
};
132143

133144
let event_loop = EventLoop::new().expect("couldn't create eventloop");
134145
let window_size = Size2D::new(WINDOW_WIDTH, WINDOW_HEIGHT);
@@ -177,22 +188,26 @@ fn main() {
177188
window_size,
178189
);
179190

180-
event_loop.run(move |event, target| match event {
181-
Event::WindowEvent {
182-
event: WindowEvent::CloseRequested,
183-
..
184-
}
185-
| Event::DeviceEvent {
186-
event:
187-
DeviceEvent::Key(RawKeyEvent {
188-
physical_key: PhysicalKey::Code(KeyCode::Escape),
189-
..
190-
}),
191-
..
192-
} => target.exit(),
193-
_ => { app.tick(true); target.set_control_flow(ControlFlow::Poll) }
194-
}).expect("failed to run event loop");
195-
191+
event_loop
192+
.run(move |event, target| match event {
193+
Event::WindowEvent {
194+
event: WindowEvent::CloseRequested,
195+
..
196+
}
197+
| Event::DeviceEvent {
198+
event:
199+
DeviceEvent::Key(RawKeyEvent {
200+
physical_key: PhysicalKey::Code(KeyCode::Escape),
201+
..
202+
}),
203+
..
204+
} => target.exit(),
205+
_ => {
206+
app.tick(true);
207+
target.set_control_flow(ControlFlow::Poll)
208+
}
209+
})
210+
.expect("failed to run event loop");
196211
}
197212
pub struct App {
198213
main_from_worker_receiver: Receiver<Frame>,
@@ -213,7 +228,6 @@ impl Drop for App {
213228
}
214229

215230
impl App {
216-
217231
pub fn new(
218232
connection: Connection,
219233
adapter: Adapter,

surfman/src/chains.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
2323
#![allow(missing_docs)]
2424

25-
use crate::{ContextID, Error, SurfaceAccess, SurfaceInfo, SurfaceType};
2625
use crate::device::Device as DeviceAPI;
26+
use crate::{ContextID, Error, SurfaceAccess, SurfaceInfo, SurfaceType};
2727
use euclid::default::Size2D;
2828
use fnv::{FnvHashMap, FnvHashSet};
2929
use log::debug;

surfman/src/connection.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,11 @@ pub trait Connection: Sized {
5656

5757
/// Opens the display connection corresponding to the given `RawDisplayHandle`.
5858
#[cfg(feature = "sm-raw-window-handle-05")]
59-
fn from_raw_display_handle(
60-
raw_handle: rwh_05::RawDisplayHandle,
61-
) -> Result<Self, Error>;
59+
fn from_raw_display_handle(raw_handle: rwh_05::RawDisplayHandle) -> Result<Self, Error>;
6260

6361
/// Opens the display connection corresponding to the given `DisplayHandle`.
6462
#[cfg(feature = "sm-raw-window-handle-06")]
65-
fn from_display_handle(
66-
handle: rwh_06::DisplayHandle,
67-
) -> Result<Self, Error>;
63+
fn from_display_handle(handle: rwh_06::DisplayHandle) -> Result<Self, Error>;
6864

6965
/// Creates a native widget from a raw pointer
7066
unsafe fn create_native_widget_from_ptr(

surfman/src/implementation/connection.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -72,17 +72,13 @@ impl ConnectionInterface for Connection {
7272

7373
#[inline]
7474
#[cfg(feature = "sm-raw-window-handle-05")]
75-
fn from_raw_display_handle(
76-
raw_handle: rwh_05::RawDisplayHandle,
77-
) -> Result<Connection, Error> {
75+
fn from_raw_display_handle(raw_handle: rwh_05::RawDisplayHandle) -> Result<Connection, Error> {
7876
Connection::from_raw_display_handle(raw_handle)
7977
}
8078

8179
#[inline]
8280
#[cfg(feature = "sm-raw-window-handle-06")]
83-
fn from_display_handle(
84-
handle: rwh_06::DisplayHandle,
85-
) -> Result<Connection, Error> {
81+
fn from_display_handle(handle: rwh_06::DisplayHandle) -> Result<Connection, Error> {
8682
Connection::from_display_handle(handle)
8783
}
8884

surfman/src/platform/android/connection.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -99,17 +99,13 @@ impl Connection {
9999

100100
/// Opens the display connection corresponding to the given raw display handle.
101101
#[cfg(feature = "sm-raw-window-handle-05")]
102-
pub fn from_raw_display_handle(
103-
_: rwh_05::RawDisplayHandle,
104-
) -> Result<Connection, Error> {
102+
pub fn from_raw_display_handle(_: rwh_05::RawDisplayHandle) -> Result<Connection, Error> {
105103
Ok(Connection)
106104
}
107105

108106
/// Opens the display connection corresponding to the given `DisplayHandle`.
109107
#[cfg(feature = "sm-raw-window-handle-06")]
110-
pub fn from_display_handle(
111-
_: rwh_06::DisplayHandle,
112-
) -> Result<Connection, Error> {
108+
pub fn from_display_handle(_: rwh_06::DisplayHandle) -> Result<Connection, Error> {
113109
Ok(Connection)
114110
}
115111

surfman/src/platform/android/context.rs

+11-5
Original file line numberDiff line numberDiff line change
@@ -316,11 +316,17 @@ impl Device {
316316
context::get_proc_address(symbol_name)
317317
}
318318

319-
pub(crate) fn context_to_egl_config(
320-
&self,
321-
context: &Context,
322-
) -> EGLConfig {
323-
unsafe { context::egl_config_from_id(self.egl_display, context::get_context_attr(self.egl_display, context.egl_context, egl::CONFIG_ID as EGLint)) }
319+
pub(crate) fn context_to_egl_config(&self, context: &Context) -> EGLConfig {
320+
unsafe {
321+
context::egl_config_from_id(
322+
self.egl_display,
323+
context::get_context_attr(
324+
self.egl_display,
325+
context.egl_context,
326+
egl::CONFIG_ID as EGLint,
327+
),
328+
)
329+
}
324330
}
325331

326332
pub(crate) fn temporarily_make_context_current(

surfman/src/platform/generic/multi/connection.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,7 @@ where
199199
) -> Result<Connection<Def, Alt>, Error> {
200200
match <Def::Connection>::from_display_handle(handle) {
201201
Ok(connection) => Ok(Connection::Default(connection)),
202-
Err(_) => {
203-
<Alt::Connection>::from_display_handle(handle).map(Connection::Alternate)
204-
}
202+
Err(_) => <Alt::Connection>::from_display_handle(handle).map(Connection::Alternate),
205203
}
206204
}
207205

@@ -325,9 +323,7 @@ where
325323
}
326324

327325
#[cfg(feature = "sm-raw-window-handle-06")]
328-
fn from_display_handle(
329-
handle: rwh_06::DisplayHandle,
330-
) -> Result<Connection<Def, Alt>, Error> {
326+
fn from_display_handle(handle: rwh_06::DisplayHandle) -> Result<Connection<Def, Alt>, Error> {
331327
Connection::from_display_handle(handle)
332328
}
333329

surfman/src/platform/macos/cgl/connection.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ impl Connection {
154154
AppKit(handle) => {
155155
let ns_view = handle.ns_view.as_ptr() as id;
156156
// https://developer.apple.com/documentation/appkit/nsview/1483301-window
157-
let ns_window: id = unsafe{ msg_send![ns_view, window] };
157+
let ns_window: id = unsafe { msg_send![ns_view, window] };
158158
Ok(NativeWidget {
159159
// Increment the nsview's reference count with retain. See:
160160
// https://developer.apple.com/documentation/objectivec/1418956-nsobject/1571946-retain

surfman/src/platform/macos/system/connection.rs

+3-7
Original file line numberDiff line numberDiff line change
@@ -120,17 +120,13 @@ impl Connection {
120120

121121
/// Opens the display connection corresponding to the given `RawDisplayHandle`.
122122
#[cfg(feature = "sm-raw-window-handle-05")]
123-
pub fn from_raw_display_handle(
124-
_: rwh_05::RawDisplayHandle,
125-
) -> Result<Connection, Error> {
123+
pub fn from_raw_display_handle(_: rwh_05::RawDisplayHandle) -> Result<Connection, Error> {
126124
Connection::new()
127125
}
128126

129127
/// Opens the display connection corresponding to the given `DisplayHandle`.
130128
#[cfg(feature = "sm-raw-window-handle-06")]
131-
pub fn from_display_handle(
132-
_: rwh_06::DisplayHandle,
133-
) -> Result<Connection, Error> {
129+
pub fn from_display_handle(_: rwh_06::DisplayHandle) -> Result<Connection, Error> {
134130
Connection::new()
135131
}
136132

@@ -179,7 +175,7 @@ impl Connection {
179175
AppKit(handle) => {
180176
let ns_view = handle.ns_view.as_ptr() as id;
181177
// https://developer.apple.com/documentation/appkit/nsview/1483301-window
182-
let ns_window: id = unsafe{ msg_send![ns_view, window] };
178+
let ns_window: id = unsafe { msg_send![ns_view, window] };
183179
Ok(NativeWidget {
184180
// Increment the nsview's reference count with retain. See:
185181
// https://developer.apple.com/documentation/objectivec/1418956-nsobject/1571946-retain

surfman/src/platform/unix/generic/connection.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -136,17 +136,13 @@ impl Connection {
136136

137137
/// Opens the display connection corresponding to the given `RawDisplayHandle`.
138138
#[cfg(feature = "sm-raw-window-handle-05")]
139-
pub fn from_raw_display_handle(
140-
_: rwh_05::RawDisplayHandle,
141-
) -> Result<Connection, Error> {
139+
pub fn from_raw_display_handle(_: rwh_05::RawDisplayHandle) -> Result<Connection, Error> {
142140
Err(Error::IncompatibleNativeWidget)
143141
}
144142

145143
/// Opens the display connection corresponding to the given `DisplayHandle`.
146144
#[cfg(feature = "sm-raw-window-handle-06")]
147-
pub fn from_display_handle(
148-
_: rwh_06::DisplayHandle,
149-
) -> Result<Connection, Error> {
145+
pub fn from_display_handle(_: rwh_06::DisplayHandle) -> Result<Connection, Error> {
150146
Err(Error::IncompatibleNativeWidget)
151147
}
152148

surfman/src/platform/unix/wayland/connection.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -175,14 +175,14 @@ impl Connection {
175175

176176
/// Opens the display connection corresponding to the given `DisplayHandle`.
177177
#[cfg(feature = "sm-raw-window-handle-06")]
178-
pub fn from_display_handle(
179-
handle: rwh_06::DisplayHandle,
180-
) -> Result<Connection, Error> {
178+
pub fn from_display_handle(handle: rwh_06::DisplayHandle) -> Result<Connection, Error> {
181179
use rwh_06::RawDisplayHandle::Wayland;
182180
use rwh_06::WaylandDisplayHandle;
183181
unsafe {
184182
let wayland_display = match handle.as_raw() {
185-
Wayland(WaylandDisplayHandle { display, .. }) => display.as_ptr() as *mut wl_display,
183+
Wayland(WaylandDisplayHandle { display, .. }) => {
184+
display.as_ptr() as *mut wl_display
185+
}
186186
_ => return Err(Error::IncompatibleRawDisplayHandle),
187187
};
188188

surfman/src/platform/unix/x11/connection.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,7 @@ impl Connection {
206206

207207
/// Opens the display connection corresponding to the given `DisplayHandle`.
208208
#[cfg(feature = "sm-raw-window-handle-06")]
209-
pub fn from_display_handle(
210-
handle: rwh_06::DisplayHandle,
211-
) -> Result<Connection, Error> {
209+
pub fn from_display_handle(handle: rwh_06::DisplayHandle) -> Result<Connection, Error> {
212210
use rwh_06::RawDisplayHandle::Xcb;
213211
use rwh_06::RawDisplayHandle::Xlib;
214212
use rwh_06::XlibDisplayHandle;

surfman/src/platform/windows/angle/connection.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -130,17 +130,13 @@ impl Connection {
130130

131131
/// Opens the display connection corresponding to the given `RawDisplayHandle`.
132132
#[cfg(feature = "sm-raw-window-handle-05")]
133-
pub fn from_raw_display_handle(
134-
_: rwh_05::RawDisplayHandle,
135-
) -> Result<Connection, Error> {
133+
pub fn from_raw_display_handle(_: rwh_05::RawDisplayHandle) -> Result<Connection, Error> {
136134
Connection::new()
137135
}
138136

139137
/// Opens the display connection corresponding to the given `DisplayHandle`.
140138
#[cfg(feature = "sm-raw-window-handle-06")]
141-
pub fn from_display_handle(
142-
_: rwh_06::DisplayHandle,
143-
) -> Result<Connection, Error> {
139+
pub fn from_display_handle(_: rwh_06::DisplayHandle) -> Result<Connection, Error> {
144140
Connection::new()
145141
}
146142

0 commit comments

Comments
 (0)