Skip to content

Commit 3d001fa

Browse files
committed
fix let_underscore_lock lint
[Recently][1] the [fix_underscore_lock][2] lint was improved and throws now (as of the upcoming rust 1.77) an error. Therefore I created separate methods for locking only `WallpaperInner`. An alternative could be that the `_` is converted to `_temp` and then the next statement could be `drop(_temp)` to stay with the current behaviour but silence the lint. [1]: rust-lang/rust#119710 [2]: https://doc.rust-lang.org/beta/nightly-rustc/rustc_lint/let_underscore/static.LET_UNDERSCORE_LOCK.html
1 parent ad3d406 commit 3d001fa

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

daemon/src/wallpaper.rs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ impl Wallpaper {
143143
}
144144

145145
pub fn get_dimensions(&self) -> (u32, u32) {
146-
let (inner, _) = self.lock();
146+
let inner = self.lock_inner();
147147
let width = inner.width.get() as u32;
148148
let height = inner.height.get() as u32;
149149
let scale_factor = inner.scale_factor.get() as u32;
@@ -156,10 +156,20 @@ impl Wallpaper {
156156
}
157157

158158
#[inline]
159-
fn lock_inner_mut(&self) -> (RwLockWriteGuard<WallpaperInner>, MutexGuard<SlotPool>) {
159+
fn lock_mut(&self) -> (RwLockWriteGuard<WallpaperInner>, MutexGuard<SlotPool>) {
160160
(self.inner.write().unwrap(), self.pool.lock().unwrap())
161161
}
162162

163+
#[inline]
164+
fn lock_inner(&self) -> RwLockReadGuard<WallpaperInner> {
165+
self.inner.read().unwrap()
166+
}
167+
168+
#[inline]
169+
fn lock_inner_mut(&self) -> RwLockWriteGuard<WallpaperInner> {
170+
self.inner.write().unwrap()
171+
}
172+
163173
pub fn canvas_change<F, T>(&self, f: F) -> T
164174
where
165175
F: FnOnce(&mut [u8]) -> T,
@@ -182,7 +192,7 @@ impl Wallpaper {
182192

183193
#[inline]
184194
pub fn get_img_info(&self) -> BgImg {
185-
self.lock().0.img.clone()
195+
self.lock_inner().img.clone()
186196
}
187197

188198
#[inline]
@@ -215,7 +225,7 @@ impl Wallpaper {
215225

216226
pub fn set_img_info(&self, img_info: BgImg) {
217227
log::debug!("output {} - drawing: {}", self.output_id, img_info);
218-
self.lock_inner_mut().0.img = img_info;
228+
self.lock_inner_mut().img = img_info;
219229
}
220230

221231
pub fn draw(&self) {
@@ -244,7 +254,7 @@ impl Wallpaper {
244254
if let Some(s) = scale_factor {
245255
self.layer_surface.set_buffer_scale(s.get() as u32).unwrap();
246256
}
247-
let (mut inner, mut pool) = self.lock_inner_mut();
257+
let (mut inner, mut pool) = self.lock_mut();
248258
let width = width.unwrap_or(inner.width);
249259
let height = height.unwrap_or(inner.height);
250260
let scale_factor = scale_factor.unwrap_or(inner.scale_factor);

0 commit comments

Comments
 (0)