macro_rules! type_match {
($value:expr, $($type:ty => $handler:expr),+ $(,)?) => { ... };
}Expand description
Matches a value against multiple type patterns using a convenient macro syntax.
§Arguments
$value- The value to match$type- The type to match against$handler- The closure to handle the matched type
§Examples
use rusty_typesh::type_match;
let value = 42i32;
let result = type_match!(
value,
i32 => |x: &i32| format!("Integer: {}", x),
String => |x: &String| format!("String: {}", x)
);