Skip to content

Commit b0d6ffb

Browse files
ids1024jackpot51
authored andcommitted
Fix clippy lints
1 parent f193f10 commit b0d6ffb

File tree

4 files changed

+15
-19
lines changed

4 files changed

+15
-19
lines changed

examples/animation.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,21 +67,18 @@ fn main() {
6767
fn pre_render_frames(width: usize, height: usize) -> Vec<Vec<u32>>{
6868
let render = |frame_id|{
6969
let elapsed = ((frame_id as f64)/(60.0))*2.0*PI;
70-
let buffer = (0..((width * height) as usize))
70+
71+
(0..(width * height))
7172
.map(|index| {
72-
let y = ((index / (width as usize)) as f64)/(height as f64);
73-
let x = ((index % (width as usize)) as f64)/(width as f64);
73+
let y = ((index / width) as f64)/(height as f64);
74+
let x = ((index % width) as f64)/(width as f64);
7475
let red = ((((y + elapsed).sin()*0.5+0.5)*255.0).round() as u32).clamp(0, 255);
7576
let green = ((((x + elapsed).sin()*0.5+0.5)*255.0).round() as u32).clamp(0, 255);
7677
let blue = ((((y - elapsed).cos()*0.5+0.5)*255.0).round() as u32).clamp(0, 255);
7778

78-
let color = blue | (green << 8) | (red << 16);
79-
80-
color
79+
blue | (green << 8) | (red << 16)
8180
})
82-
.collect::<Vec<_>>();
83-
84-
buffer
81+
.collect::<Vec<_>>()
8582
};
8683

8784
#[cfg(target_arch = "wasm32")]

examples/winit_wrong_sized_buffer.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ fn main() {
3131

3232
match event {
3333
Event::RedrawRequested(window_id) if window_id == window.id() => {
34-
let buffer = (0..((BUFFER_WIDTH * BUFFER_HEIGHT) as usize))
34+
let buffer = (0..(BUFFER_WIDTH * BUFFER_HEIGHT))
3535
.map(|index| {
36-
let y = index / (BUFFER_WIDTH as usize);
37-
let x = index % (BUFFER_WIDTH as usize);
36+
let y = index / BUFFER_WIDTH;
37+
let x = index % BUFFER_WIDTH;
3838
let red = x % 255;
3939
let green = y % 255;
4040
let blue = (x * y) % 255;

src/wayland/buffer.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@ impl WaylandBuffer {
3333
.expect("Failed to create memfd to store buffer.");
3434
let tempfile = unsafe { File::from_raw_fd(tempfile_fd) };
3535
let pool_size = width * height * 4;
36-
let pool = shm.create_pool(tempfile.as_raw_fd(), pool_size, &qh, ());
36+
let pool = shm.create_pool(tempfile.as_raw_fd(), pool_size, qh, ());
3737
let released = Arc::new(AtomicBool::new(true));
3838
let buffer = pool.create_buffer(
3939
0,
4040
width,
4141
height,
4242
width * 4,
4343
wl_shm::Format::Xrgb8888,
44-
&qh,
44+
qh,
4545
released.clone(),
4646
);
4747
Self {
@@ -129,9 +129,8 @@ impl Dispatch<wl_buffer::WlBuffer, Arc<AtomicBool>> for State {
129129
_: &Connection,
130130
_: &QueueHandle<State>,
131131
) {
132-
match event {
133-
wl_buffer::Event::Release => released.store(true, Ordering::SeqCst),
134-
_ => {}
132+
if let wl_buffer::Event::Release = event {
133+
released.store(true, Ordering::SeqCst);
135134
}
136135
}
137136
}

src/wayland/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ impl WaylandImpl {
5151
"Failed to create proxy for surface ID.",
5252
)?;
5353
Ok(Self {
54-
event_queue: event_queue,
54+
event_queue,
5555
qh,
5656
surface,
5757
shm,
@@ -67,7 +67,7 @@ impl WaylandImpl {
6767
buffer
6868
} else {
6969
// If we have more than 1 unreleased buffer, destroy it
70-
if self.buffers.len() == 0 {
70+
if self.buffers.is_empty() {
7171
self.buffers.push_back(buffer);
7272
}
7373
WaylandBuffer::new(&self.shm, width, height, &self.qh)

0 commit comments

Comments
 (0)