Test if a constant variable can be used in the match arm.
This commit is contained in:
parent
e894654d68
commit
de37fa8f00
21
src/tag.rs
21
src/tag.rs
|
@ -306,3 +306,24 @@ generate_well_known_tag_constants!(
|
||||||
|
|
||||||
(InteroperabilityIndex, 0x1, "Interoperability identification"),
|
(InteroperabilityIndex, 0x1, "Interoperability identification"),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use tag;
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
// This test checks if Tag constants can be used in patterns.
|
||||||
|
#[test]
|
||||||
|
fn tag_constant_in_pattern() {
|
||||||
|
// Destructuring, which will always work.
|
||||||
|
match Tag(Context::Tiff, 0x132) {
|
||||||
|
Tag(Context::Tiff, 0x132) => {},
|
||||||
|
_ => panic!("failed to match Tag"),
|
||||||
|
}
|
||||||
|
// Matching against a constant. Test if this compiles.
|
||||||
|
match Tag(Context::Tiff, 0x132) {
|
||||||
|
tag::DateTime => {},
|
||||||
|
_ => panic!("failed to match Tag"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue