@@ -60,18 +60,50 @@ pub struct Duration {
60
60
61
61
impl Duration {
62
62
/// The duration of one second.
63
+ ///
64
+ /// # Examples
65
+ ///
66
+ /// ```
67
+ /// use std::time::Duration;
68
+ ///
69
+ /// assert_eq!(Duration::SECOND, Duration::from_secs(1));
70
+ /// ```
63
71
#[ unstable( feature = "duration_constants" , issue = "57391" ) ]
64
72
pub const SECOND : Duration = Duration :: from_secs ( 1 ) ;
65
73
66
74
/// The duration of one millisecond.
75
+ ///
76
+ /// # Examples
77
+ ///
78
+ /// ```
79
+ /// use std::time::Duration;
80
+ ///
81
+ /// assert_eq!(Duration::MILLISECOND, Duration::from_millis(1));
82
+ /// ```
67
83
#[ unstable( feature = "duration_constants" , issue = "57391" ) ]
68
84
pub const MILLISECOND : Duration = Duration :: from_millis ( 1 ) ;
69
85
70
86
/// The duration of one microsecond.
87
+ ///
88
+ /// # Examples
89
+ ///
90
+ /// ```
91
+ /// use std::time::Duration;
92
+ ///
93
+ /// assert_eq!(Duration::MICROSECOND, Duration::from_micros(1));
94
+ /// ```
71
95
#[ unstable( feature = "duration_constants" , issue = "57391" ) ]
72
96
pub const MICROSECOND : Duration = Duration :: from_micros ( 1 ) ;
73
97
74
98
/// The duration of one nanosecond.
99
+ ///
100
+ /// # Examples
101
+ ///
102
+ /// ```
103
+ /// use std::time::Duration;
104
+ ///
105
+ /// assert_eq!(Duration::NANOSECOND, Duration::from_nanos(1));
106
+ /// ```
75
107
#[ unstable( feature = "duration_constants" , issue = "57391" ) ]
76
108
pub const NANOSECOND : Duration = Duration :: from_nanos ( 1 ) ;
77
109
0 commit comments