From 6f1d9d6b6addcd2c4fc0fbe02b6fbaf874fc9de5 Mon Sep 17 00:00:00 2001 From: mcmah309 Date: Thu, 5 Dec 2024 18:58:21 +0000 Subject: [PATCH] test: Add from_for_generic_and_regular test --- tests/mod.rs | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/tests/mod.rs b/tests/mod.rs index 0ba8bb2..3bfdeea 100644 --- a/tests/mod.rs +++ b/tests/mod.rs @@ -737,7 +737,10 @@ pub mod generics { #[cfg(test)] pub mod disable { - use std::{error::Error, fmt::{Debug, Display}}; + use std::{ + error::Error, + fmt::{Debug, Display}, + }; use error_set::error_set; @@ -831,6 +834,32 @@ pub mod disable { } } +#[cfg(test)] +pub mod from_for_generic_and_regular { + use error_set::error_set; + + error_set! { + #[disable(From(E))] + X = Y || Z; + Y = { + A, + }; + Z = { + B(E), + }; + } + + #[test] + fn test() { + let y = Y::A; + let x: X = y.into(); + assert!(matches!(x, X::A)); + + let z = Z::B(std::io::Error::new(std::io::ErrorKind::Other, "oops")); + let x: X = z.into(); + assert!(matches!(x, X::B(_))); + } +} #[cfg(test)] pub mod should_not_compile_tests {