diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-07-23 08:08:33 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-07-23 14:01:45 +0800 |
| commit | 68a652ed2f51d366bb8033497e6dfe545895410e (patch) | |
| tree | d463833846248410733e196a0939c59cd67ca8a2 /doc/select.md | |
feat: scaffold crate structure and implement core macros
Add the project skeleton, LICENSE files, README, Makefile, doc
examples, and the initial implementation of `#[func]`, `invoke!`,
and `select!` procedural macros.
Diffstat (limited to 'doc/select.md')
| -rw-r--r-- | doc/select.md | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/doc/select.md b/doc/select.md new file mode 100644 index 0000000..d2330bd --- /dev/null +++ b/doc/select.md @@ -0,0 +1,22 @@ +Procedural macro that chooses between two expressions based on whether the +async feature is enabled, producing a value. + +## Explicit mode + +Each arm is labelled with a feature name. When the named feature is enabled +that arm is selected; otherwise the other arm is used. Since only one feature +is ever active at a time, the arm labelled `"sync"` effectively acts as an else +branch. + +The `!` token inverts the sense — it selects the arm when the corresponding +feature is **not** enabled. + +## Implicit mode + +Feature names are omitted; the macro inspects the token stream to decide which +expression is async. Whichever arm contains a `.await` call is treated as the +async branch. + +When neither arm contains `.await`, the first expression is assigned to the +async branch and the second to sync. The two branches trade places during +expansion so the correct one is active in each mode. |
