@@ -16,15 +16,14 @@ const MAX_DAY: u16 = 31;
1616///
1717/// Used by `DirEntry` time-related methods.
1818#[ derive( Copy , Clone , Eq , PartialEq , Debug ) ]
19+ #[ non_exhaustive]
1920pub struct Date {
2021 /// Full year - [1980, 2107]
2122 pub year : u16 ,
2223 /// Month of the year - [1, 12]
2324 pub month : u16 ,
2425 /// Day of the month - [1, 31]
2526 pub day : u16 ,
26- // Not-public field to disallow direct instantiation of this struct
27- _dummy : ( ) ,
2827}
2928
3029impl Date {
@@ -46,7 +45,6 @@ impl Date {
4645 year,
4746 month,
4847 day,
49- _dummy : ( ) ,
5048 }
5149 }
5250
@@ -56,7 +54,6 @@ impl Date {
5654 year,
5755 month,
5856 day,
59- _dummy : ( ) ,
6057 }
6158 }
6259
@@ -69,6 +66,7 @@ impl Date {
6966///
7067/// Used by `DirEntry` time-related methods.
7168#[ derive( Copy , Clone , Eq , PartialEq , Debug ) ]
69+ #[ non_exhaustive]
7270pub struct Time {
7371 /// Hours after midnight - [0, 23]
7472 pub hour : u16 ,
@@ -78,8 +76,6 @@ pub struct Time {
7876 pub sec : u16 ,
7977 /// Milliseconds after the second - [0, 999]
8078 pub millis : u16 ,
81- // Not-public field to disallow direct instantiation of this struct
82- _dummy : ( ) ,
8379}
8480
8581impl Time {
@@ -104,7 +100,6 @@ impl Time {
104100 min,
105101 sec,
106102 millis,
107- _dummy : ( ) ,
108103 }
109104 }
110105
@@ -118,7 +113,6 @@ impl Time {
118113 min,
119114 sec,
120115 millis,
121- _dummy : ( ) ,
122116 }
123117 }
124118
@@ -135,19 +129,18 @@ impl Time {
135129///
136130/// Used by `DirEntry` time-related methods.
137131#[ derive( Copy , Clone , Eq , PartialEq , Debug ) ]
132+ #[ non_exhaustive]
138133pub struct DateTime {
139134 /// A date part
140135 pub date : Date ,
141136 // A time part
142137 pub time : Time ,
143- // Not-public field to disallow direct instantiation of this struct
144- _dummy : ( ) ,
145138}
146139
147140impl DateTime {
148141 #[ must_use]
149142 pub fn new ( date : Date , time : Time ) -> Self {
150- Self { date, time, _dummy : ( ) }
143+ Self { date, time }
151144 }
152145
153146 pub ( crate ) fn decode ( dos_date : u16 , dos_time : u16 , dos_time_hi_res : u8 ) -> Self {
@@ -184,7 +177,6 @@ impl From<chrono::Date<Local>> for Date {
184177 year,
185178 month : date. month ( ) as u16 , // safe cast: value in range [1, 12]
186179 day : date. day ( ) as u16 , // safe cast: value in range [1, 31]
187- _dummy : ( ) ,
188180 }
189181 }
190182}
@@ -194,14 +186,13 @@ impl From<chrono::DateTime<Local>> for DateTime {
194186 fn from ( date_time : chrono:: DateTime < Local > ) -> Self {
195187 let millis_leap = date_time. nanosecond ( ) / 1_000_000 ; // value in the range [0, 1999] (> 999 if leap second)
196188 let millis = millis_leap. min ( 999 ) ; // during leap second set milliseconds to 999
197- #[ allow( clippy:: cast_possible_truncation) ]
198189 let date = Date :: from ( date_time. date ( ) ) ;
190+ #[ allow( clippy:: cast_possible_truncation) ]
199191 let time = Time {
200192 hour : date_time. hour ( ) as u16 , // safe cast: value in range [0, 23]
201193 min : date_time. minute ( ) as u16 , // safe cast: value in range [0, 59]
202194 sec : date_time. second ( ) as u16 , // safe cast: value in range [0, 59]
203195 millis : millis as u16 , // safe cast: value in range [0, 999]
204- _dummy : ( ) ,
205196 } ;
206197 Self :: new ( date, time)
207198 }
0 commit comments