Skip to content

Commit 552b6ac

Browse files
committed
chore: fix warnings
1 parent 841193b commit 552b6ac

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

screencapturekit-sys/src/stream_error_handler.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::{ptr::addr_of, sync::Once};
1+
use std::sync::Once;
22

33
use objc::{
44
class,
@@ -19,10 +19,10 @@ pub(crate) struct UnsafeSCStreamErrorHandler {}
1919
unsafe impl Message for UnsafeSCStreamErrorHandler {}
2020

2121
use once_cell::sync::Lazy;
22-
use std::sync::RwLock;
2322
use std::collections::HashMap;
23+
use std::sync::RwLock;
2424
static ERROR_HANDLERS: Lazy<RwLock<HashMap<usize, Box<dyn UnsafeSCStreamError + Send + Sync>>>> =
25-
Lazy::new(|| RwLock::new(HashMap::new()));
25+
Lazy::new(|| RwLock::new(HashMap::new()));
2626

2727
impl INSObject for UnsafeSCStreamErrorHandler {
2828
fn class() -> &'static Class {
@@ -62,12 +62,15 @@ impl UnsafeSCStreamErrorHandler {
6262
unsafe {
6363
let obj = &mut *(self as *mut _ as *mut Object);
6464
let hash = self.hash_code();
65-
ERROR_HANDLERS.write().unwrap().insert(hash, Box::new(error_handler));
66-
obj.set_ivar("_hash", hash as usize);
65+
ERROR_HANDLERS
66+
.write()
67+
.unwrap()
68+
.insert(hash, Box::new(error_handler));
69+
obj.set_ivar("_hash", hash);
6770
}
6871
}
6972
// Error handlers passed into here will currently live forever inside the statically
70-
// allocated map.
73+
// allocated map.
7174
// TODO: Remove the handler from the HashMap whenever the associated stream is dropped.
7275
pub fn init(error_handler: impl UnsafeSCStreamError) -> Id<Self> {
7376
let mut handle = Self::new();
@@ -79,7 +82,7 @@ impl UnsafeSCStreamErrorHandler {
7982
#[cfg(test)]
8083
mod tests {
8184
use std::ptr;
82-
use std::sync::mpsc::{SyncSender, sync_channel};
85+
use std::sync::mpsc::{sync_channel, SyncSender};
8386

8487
use super::*;
8588

screencapturekit/src/sc_error_handler.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use screencapturekit_sys::stream_error_handler::UnsafeSCStreamError;
33
// TODO: It might make sense to be a little more precise with lifetimes, than 'static.
44
// The lifetime could be potentially only as long as the relevant Stream, if the
55
// handler was dropped correctly together with the stream. For now the handler is never
6-
// dropped and lives forever inside a statically allocated HashMap. See the relevant
6+
// dropped and lives forever inside a statically allocated HashMap. See the relevant
77
// code in screencapturekit-sys crate.
88
pub trait StreamErrorHandler: Send + Sync + 'static {
99
fn on_error(&self);

0 commit comments

Comments
 (0)