diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index b8cac72..b652e6e 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -40,7 +40,7 @@ jobs: matrix: os: [ubuntu-latest, macos-latest] rust: - - 1.65.0 + - 1.66.0 target: - "" features: diff --git a/src/unix.rs b/src/unix.rs index c36520a..707156e 100644 --- a/src/unix.rs +++ b/src/unix.rs @@ -1,6 +1,9 @@ use crate::{Clock, LeapIndicator, TimeOffset, Timestamp}; use std::{ - os::unix::prelude::{AsRawFd, FromRawFd, RawFd}, + os::{ + fd::IntoRawFd, + unix::prelude::{FromRawFd, RawFd}, + }, path::Path, time::Duration, }; @@ -46,9 +49,12 @@ impl UnixClock { /// ``` pub fn open(path: impl AsRef) -> std::io::Result { let file = std::fs::File::open(path)?; - Ok(Self::safe_from_raw_fd(file.as_raw_fd())) + Ok(Self::safe_from_raw_fd(file.into_raw_fd())) } + // Cosnume an fd and produce a clock id. Clock id is only valid + // so long as the fd is open, so the RawFd here should + // not be borrowed. fn safe_from_raw_fd(fd: RawFd) -> Self { let clock = ((!(fd as libc::clockid_t)) << 3) | 3;