1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
#![warn(
clippy::default_trait_access,
clippy::dbg_macro,
clippy::print_stdout,
clippy::unimplemented,
clippy::use_self,
missing_copy_implementations,
missing_docs,
non_snake_case,
non_upper_case_globals,
rust_2018_idioms,
unreachable_pub
)]
use enum_as_inner::EnumAsInner;
pub mod name_collisions {
#![allow(dead_code, missing_copy_implementations, missing_docs)]
pub struct Option;
pub struct Some;
pub struct None;
pub struct Result;
pub struct Ok;
pub struct Err;
}
#[allow(unused_imports)]
use name_collisions::*;
#[allow(dead_code)]
#[derive(Debug, Clone, Copy, EnumAsInner)]
enum WithGenerics<T: Clone + Copy> {
A(T),
B(T),
}
#[test]
fn with_generics() {
let mut with_generics = WithGenerics::A(100);
assert!(with_generics.is_a());
assert!(!with_generics.is_b());
assert!(with_generics.as_a().is_some());
assert!(with_generics.as_b().is_none());
assert_eq!(with_generics.into_a().unwrap(), 100);
assert_eq!(*with_generics.as_a().unwrap(), 100);
assert_eq!(*with_generics.as_a_mut().unwrap(), 100);
assert!(with_generics.into_b().is_err());
assert!(with_generics.as_b().is_none());
assert!(with_generics.as_b_mut().is_none());
}
|