Skip to content

How to handle a missing list value? #305

Closed Answered by d-frey
0x8000-0000 asked this question in Q&A
Discussion options

You must be logged in to vote

Just use sor<>:

struct Foo : ... {};
struct Bar : success {};

struct OptFoo : sor< Foo, Bar > {};

Which will trigger the action for Foo if it matches, the action for Bar otherwise.

If you want to fail the whole rule when Foo doesn't match, but you still want an action for Bar to be triggered when it fails, you can use:

struct FooWithFailActionBar : sor< Foo, seq< Bar, failure > > {};

Replies: 4 comments 2 replies

Comment options

You must be logged in to vote
2 replies
@0x8000-0000
Comment options

@rowlesmr
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by 0x8000-0000
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants