| 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 | #[allow(dead_code)] |
| 30 | #[derive(Debug, Clone, Copy, EnumAsInner)] |
| 31 | enum WithGenerics<T: Clone + Copy> { |
| 32 | A(T), |
| 33 | B(T), |
| 34 | } |
| 35 | |
| 36 | #[test] |
| 37 | fn with_generics() { |
| 38 | let mut with_generics = WithGenerics::A(100); |
| 39 | |
| 40 | assert!(with_generics.is_a()); |
| 41 | assert!(!with_generics.is_b()); |
| 42 | |
| 43 | assert!(with_generics.as_a().is_some()); |
| 44 | assert!(with_generics.as_b().is_none()); |
| 45 | |
| 46 | assert_eq!(with_generics.into_a().unwrap(), 100); |
| 47 | assert_eq!(*with_generics.as_a().unwrap(), 100); |
| 48 | assert_eq!(*with_generics.as_a_mut().unwrap(), 100); |
| 49 | |
| 50 | assert!(with_generics.into_b().is_err()); |
| 51 | assert!(with_generics.as_b().is_none()); |
| 52 | assert!(with_generics.as_b_mut().is_none()); |
| 53 | } |