Skip to content

Commit 6de9f7b

Browse files
committed
Enable #[non_exhaustive] on Units enums.
Previously the `#[doc(hidden)] __nonexhaustive` trick was used until `uom`'s minimum supported Rust version was able to be increased to 1.40.0.
1 parent 147907c commit 6de9f7b

File tree

1 file changed

+1
-10
lines changed

1 file changed

+1
-10
lines changed

src/quantity.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -153,15 +153,12 @@ macro_rules! quantity {
153153

154154
/// Unit enum.
155155
#[allow(non_camel_case_types)]
156-
//#[non_exhaustive] // Requires rustc 1.40.0
156+
#[non_exhaustive]
157157
#[allow(clippy::manual_non_exhaustive)]
158158
#[derive(Debug, Clone, Copy)]
159159
pub enum Units {
160160
$(#[doc=$plural]
161161
$unit($unit),)+
162-
163-
#[doc(hidden)]
164-
__nonexhaustive,
165162
}
166163

167164
impl Units {
@@ -171,8 +168,6 @@ macro_rules! quantity {
171168
pub fn abbreviation(&self) -> &'static str {
172169
match self {
173170
$(Units::$unit(_) => <$unit as __system::Unit>::abbreviation(),)+
174-
175-
Units::__nonexhaustive => "unknown",
176171
}
177172
}
178173

@@ -182,8 +177,6 @@ macro_rules! quantity {
182177
pub fn singular(&self) -> &'static str {
183178
match self {
184179
$(Units::$unit(_) => <$unit as __system::Unit>::singular(),)+
185-
186-
Units::__nonexhaustive => "unknown",
187180
}
188181
}
189182

@@ -193,8 +186,6 @@ macro_rules! quantity {
193186
pub fn plural(&self) -> &'static str {
194187
match self {
195188
$(Units::$unit(_) => <$unit as __system::Unit>::plural(),)+
196-
197-
Units::__nonexhaustive => "unknown",
198189
}
199190
}
200191
}

0 commit comments

Comments
 (0)