This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type AnyState = { step: string }; | |
type AnyActionMap = Record<string, (...args: any[]) => unknown>; | |
type AnyAction<State extends AnyState> = { | |
[S in State['step']]?: ( | |
state: { step: S } & State, | |
setState: (newState: SetStateAction<State>) => void | |
) => AnyActionMap; | |
}; | |
type StateWithActions< |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Credit to https://danielkeep.github.io/practical-intro-to-macros.html | |
macro_rules! count_exprs { | |
() => (0); | |
($head:expr $(, $tail:expr)*) => (1 + count_exprs!($($tail),*)); | |
} | |
macro_rules! recurrence { | |
( $seq:ident [ $ind:ident ]: $sty:ty = $recur:expr, $($inits:expr),+) => { | |
{ |