Skip to content

Commit

Permalink
Rename CFRunLoopMode constructors for clippy::should_implement_trait …
Browse files Browse the repository at this point in the history
…lint
  • Loading branch information
kevinmehall committed Aug 14, 2024
1 parent 8118d6a commit db98303
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion core-foundation/src/filedescriptor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ mod test {
let run_loop = CFRunLoop::get_current();
let source = CFRunLoopSource::from_file_descriptor(&cf_fd, 0);
assert!(source.is_some());
run_loop.add_source(&source.unwrap(), CFRunLoopMode::default());
run_loop.add_source(&source.unwrap(), CFRunLoopMode::default_mode());

info.value = 0;
cf_fd.enable_callbacks(kCFFileDescriptorReadCallBack);
Expand Down
17 changes: 10 additions & 7 deletions core-foundation/src/runloop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ impl<'a> CFRunLoopMode<'a> {
}

#[doc(alias = "kCFRunLoopCommonModes")]
pub fn common() -> CFRunLoopMode<'static> {
pub fn common_modes() -> CFRunLoopMode<'static> {
unsafe { CFRunLoopMode(kCFRunLoopCommonModes, PhantomData) }
}

#[doc(alias = "kCFRunLoopDefaultMode")]
pub fn default() -> CFRunLoopMode<'static> {
pub fn default_mode() -> CFRunLoopMode<'static> {
unsafe { CFRunLoopMode(kCFRunLoopDefaultMode, PhantomData) }
}
}
Expand Down Expand Up @@ -240,7 +240,7 @@ mod test {

let run_loop_timer =
CFRunLoopTimer::new(now + 0.20f64, 0f64, 0, 0, timer_popped, &mut context);
run_loop.add_timer(&run_loop_timer, CFRunLoopMode::default());
run_loop.add_timer(&run_loop_timer, CFRunLoopMode::default_mode());

CFRunLoop::run_current();
let elapsed = elapsed_rx.try_recv().unwrap();
Expand Down Expand Up @@ -294,7 +294,7 @@ mod test {
};

let runloop = CFRunLoop::get_current();
runloop.add_observer(&observer, CFRunLoopMode::default());
runloop.add_observer(&observer, CFRunLoopMode::default_mode());

let timer = CFRunLoopTimer::new(
CFDate::now().abs_time() + 1f64,
Expand All @@ -304,10 +304,13 @@ mod test {
observe_timer_popped,
null_mut(),
);
runloop.add_timer(&timer, CFRunLoopMode::default());
runloop.add_timer(&timer, CFRunLoopMode::default_mode());

let result =
CFRunLoop::run_in_mode(CFRunLoopMode::default(), Duration::from_secs(10), false);
let result = CFRunLoop::run_in_mode(
CFRunLoopMode::default_mode(),
Duration::from_secs(10),
false,
);

assert_eq!(result, CFRunLoopRunResult::Stopped);

Expand Down
2 changes: 1 addition & 1 deletion core-graphics/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ unsafe extern "C" fn cg_event_tap_callback_internal(
/// .mach_port
/// .create_runloop_source(0)
/// .expect("Somethings is bad ");
/// current.add_source(&loop_source, CFRunLoopMode::common());
/// current.add_source(&loop_source, CFRunLoopMode::common_modes());
/// tap.enable();
/// CFRunLoop::run_current();
/// },
Expand Down

0 comments on commit db98303

Please sign in to comment.