Conversation
|
This would somehow also address #24 by implementing |
|
Perform a compile-time style match over a single source type against one or This macro is the type-level analogue to [ Internally this uses [ SyntaxBasic form (boolean style matching on type only): match_ty!(From, {
Type1 => expr1,
Type2 | Type3 => expr2,
_ => default_expr,
})A leading Function‑capturing form (obtain zero‑cost cast function pointers): match_ty!(From, (from_fn, to_fn), {
TargetType => expr_using_from_fn_and_to_fn,
_ => fallback,
})In a matching arm, An entirely empty arm set is permitted: Differences from [
|
Fixes #35.
This PR is based on #36, I'd like to perform rebase when #36 landed.
try_cast_from,get_cast_fnsforTryCast*TryCasttrait should implementedCAST_METHOD(just for test, tell which trait is actually calling on),can_cast,unchecked_fromandunchecked_to, other methods would derived from these methodscan_cast!,get_cast_fns!andmatch_ty!macrosIt would be better naming
match_typetomatch_castmatch_tyin this PR tomatch_typeBut for non-breaking change, we naming it
match_ty