Skip to content

Commit

Permalink
chore: fix clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
xu-cheng committed Apr 5, 2021
1 parent 50b6e74 commit 4bd9bb1
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 20 deletions.
18 changes: 9 additions & 9 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ fn gen_darwin_binding() {

let bindings = bindgen::Builder::default()
.header("src/clock/darwin_wrapper.h")
.whitelist_function("mach_absolute_time")
.whitelist_function("mach_timebase_info")
.whitelist_function("pthread_mach_thread_np")
.whitelist_function("pthread_self")
.whitelist_function("thread_info")
.whitelist_type("mach_timebase_info_data_t")
.whitelist_type("thread_basic_info_data_t")
.whitelist_var("THREAD_BASIC_INFO")
.whitelist_var("__THREAD_BASIC_INFO_COUNT")
.allowlist_function("mach_absolute_time")
.allowlist_function("mach_timebase_info")
.allowlist_function("pthread_mach_thread_np")
.allowlist_function("pthread_self")
.allowlist_function("thread_info")
.allowlist_type("mach_timebase_info_data_t")
.allowlist_type("thread_basic_info_data_t")
.allowlist_var("THREAD_BASIC_INFO")
.allowlist_var("__THREAD_BASIC_INFO_COUNT")
.parse_callbacks(Box::new(bindgen::CargoCallbacks))
.layout_tests(false)
.generate()
Expand Down
9 changes: 3 additions & 6 deletions src/clock/posix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,6 @@ extern "C" {
) -> libc::c_int;
}

#[cfg(have_clock_thread_cputime_id)]
#[inline(always)]
fn get_thread_clock_id() -> Result<libc::clockid_t> {
Ok(libc::CLOCK_THREAD_CPUTIME_ID)
}

#[cfg(not(have_clock_thread_cputime_id))]
#[inline(always)]
fn get_thread_clock_id() -> Result<libc::clockid_t> {
Expand All @@ -169,6 +163,9 @@ impl Clock for ThreadClock {
tv_sec: 0,
tv_nsec: 0,
};
#[cfg(have_clock_thread_cputime_id)]
let clock_id = libc::CLOCK_THREAD_CPUTIME_ID;
#[cfg(not(have_clock_thread_cputime_id))]
let clock_id = get_thread_clock_id()?;
let ret = unsafe { libc::clock_gettime(clock_id, &mut ts) };
if ret != 0 {
Expand Down
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
//! println!("{}", timer.elapsed()); // 5.71s wall, 5.70s user + 0ns system = 5.70s CPU (99.8%)
//! ```
#![allow(clippy::upper_case_acronyms)]

mod types;
pub use types::*;

Expand Down
10 changes: 5 additions & 5 deletions src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ impl From<ProcessDuration> for ProcessTimePoint {
}
}

impl Into<ProcessDuration> for ProcessTimePoint {
fn into(self) -> ProcessDuration {
impl From<ProcessTimePoint> for ProcessDuration {
fn from(t: ProcessTimePoint) -> Self {
ProcessDuration {
real: self.real,
user: self.user,
system: self.user,
real: t.real,
user: t.user,
system: t.user,
}
}
}
Expand Down

0 comments on commit 4bd9bb1

Please sign in to comment.