From 0c732c1ed84556329a0ae33a422898c1487e253f Mon Sep 17 00:00:00 2001 From: Kevin Mehall Date: Tue, 13 Aug 2024 18:29:54 -0700 Subject: [PATCH] Rename CFRunLoopMode constructors for clippy::should_implement_trait lint --- core-foundation/src/filedescriptor.rs | 2 +- core-foundation/src/runloop.rs | 12 ++++++------ core-graphics/src/event.rs | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/core-foundation/src/filedescriptor.rs b/core-foundation/src/filedescriptor.rs index ad391eb6..985567fe 100644 --- a/core-foundation/src/filedescriptor.rs +++ b/core-foundation/src/filedescriptor.rs @@ -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); diff --git a/core-foundation/src/runloop.rs b/core-foundation/src/runloop.rs index fc6b7db5..fd175b87 100644 --- a/core-foundation/src/runloop.rs +++ b/core-foundation/src/runloop.rs @@ -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) } } } @@ -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(); @@ -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, @@ -304,10 +304,10 @@ 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); + CFRunLoop::run_in_mode(CFRunLoopMode::default_mode(), Duration::from_secs(10), false); assert_eq!(result, CFRunLoopRunResult::Stopped); diff --git a/core-graphics/src/event.rs b/core-graphics/src/event.rs index 95295382..c0dc1350 100644 --- a/core-graphics/src/event.rs +++ b/core-graphics/src/event.rs @@ -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(); /// },