From 76dd61f48bb7b39b094f4e5122337c2a7259c2e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20W=C3=B6rner?= Date: Thu, 6 Apr 2017 16:40:36 +0200 Subject: [PATCH] fixed rustdoc tests --- V2/sleep/src/lib.rs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/V2/sleep/src/lib.rs b/V2/sleep/src/lib.rs index 143e7a5..180fe9b 100644 --- a/V2/sleep/src/lib.rs +++ b/V2/sleep/src/lib.rs @@ -18,6 +18,16 @@ fn nanosleep(rqtp: *const libc::timespec, rmtp: *mut libc::timespec) -> libc::c_ /// Sleeps for the given duration. /// +/// Examples: +/// +/// ```rust +/// extern crate sleep; +/// use std::time::Duration; +/// +/// // sleep 10 ms +/// sleep::sleep(Duration::from_millis(10)); +/// ``` +/// /// Uses `clock_nanosleep` on linux and `nanosleep` on darwin. pub fn sleep(duration: Duration) -> Result { let ts = duration_to_timespec(duration); @@ -57,8 +67,11 @@ fn timespec_to_duration(timespec: libc::timespec) -> Duration { /// # Examples /// /// ```rust +/// extern crate libc; +/// extern crate sleep; +/// /// // set *round-robin* policy (default) and priority 99 (realtime) for own process -/// set_scheduler(0, libc::SCHED_RR, 99); +/// sleep::set_scheduler(0, libc::SCHED_RR, 99); /// ``` #[cfg(target_os = "linux")] pub fn set_scheduler(pid: libc::pid_t, policy: libc::c_int, priority: libc::c_int) -> libc::c_int { @@ -71,8 +84,10 @@ pub fn set_scheduler(pid: libc::pid_t, policy: libc::c_int, priority: libc::c_in /// # Examples /// /// ```rust +/// extern crate sleep; +/// /// // set *round-robin* policy (default) and priority 99 (realtime) -/// set_priority(99); +/// sleep::set_priority(99); /// ``` #[cfg(target_os = "linux")] pub fn set_priority(priority: i32) -> libc::c_int {