We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 321690c commit 4b1b305Copy full SHA for 4b1b305
library/std/src/sys/unix/time.rs
@@ -266,6 +266,7 @@ mod inner {
266
#[cfg(not(any(target_os = "macos", target_os = "ios")))]
267
mod inner {
268
use crate::fmt;
269
+ use crate::mem::MaybeUninit;
270
use crate::sys::cvt;
271
use crate::time::Duration;
272
@@ -350,9 +351,9 @@ mod inner {
350
351
352
impl Timespec {
353
pub fn now(clock: clock_t) -> Timespec {
- let mut t = Timespec { t: libc::timespec { tv_sec: 0, tv_nsec: 0 } };
354
- cvt(unsafe { libc::clock_gettime(clock, &mut t.t) }).unwrap();
355
- t
+ let mut t = MaybeUninit::uninit();
+ cvt(unsafe { libc::clock_gettime(clock, t.as_mut_ptr()) }).unwrap();
356
+ Timespec { t: unsafe { t.assume_init() } }
357
}
358
359
0 commit comments