1 #![warn(
2 clippy::default_trait_access,
3 clippy::dbg_macro,
4 clippy::print_stdout,
5 clippy::unimplemented,
6 clippy::use_self,
7 missing_copy_implementations,
8 missing_docs,
9 non_snake_case,
10 non_upper_case_globals,
11 rust_2018_idioms,
12 unreachable_pub
13 )]
14
15 use enum_as_inner::EnumAsInner;
16
17 pub mod name_collisions {
18 #![allow(dead_code, missing_copy_implementations, missing_docs)]
19 pub struct Option;
20 pub struct Some;
21 pub struct None;
22 pub struct Result;
23 pub struct Ok;
24 pub struct Err;
25 }
26 #[allow(unused_imports)]
27 use name_collisions::*;
28
29 #[derive(Debug, EnumAsInner)]
30 #[allow(non_camel_case_types)]
31 #[allow(clippy::upper_case_acronyms)]
32 enum MixedCaseVariants {
33 XMLIsNotCool,
34 Rust_IsCoolThough(u32),
35 YMCA { named: i16 },
36 }
37
38 #[test]
test_xml_unit()39 fn test_xml_unit() {
40 let mixed = MixedCaseVariants::XMLIsNotCool;
41
42 assert!(mixed.is_xml_is_not_cool());
43 assert!(mixed.as_rust_is_cool_though().is_none());
44 assert!(mixed.as_ymca().is_none());
45 }
46
47 #[test]
test_rust_unnamed()48 fn test_rust_unnamed() {
49 let mixed = MixedCaseVariants::Rust_IsCoolThough(42);
50
51 assert!(!mixed.is_xml_is_not_cool());
52 assert!(mixed.as_rust_is_cool_though().is_some());
53 assert!(mixed.as_ymca().is_none());
54
55 assert_eq!(*mixed.as_rust_is_cool_though().unwrap(), 42);
56 assert_eq!(mixed.into_rust_is_cool_though().unwrap(), 42);
57 }
58
59 #[test]
test_ymca_named()60 fn test_ymca_named() {
61 let mixed = MixedCaseVariants::YMCA { named: -32_768 };
62
63 assert!(!mixed.is_xml_is_not_cool());
64 assert!(mixed.as_rust_is_cool_though().is_none());
65 assert!(mixed.as_ymca().is_some());
66
67 assert_eq!(*mixed.as_ymca().unwrap(), (-32_768));
68 assert_eq!(mixed.into_ymca().unwrap(), (-32_768));
69 }
70