Skip to content

Commit 1c77769

Browse files
committed
alternatives
1 parent e5c4fde commit 1c77769

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

text/0000-postfix-match.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ While I am not at liberty to share the codebase, the former is equivalent to som
143143
I see on some of our codebases at work.
144144

145145
## tap (pipelines)
146+
[guide-level-explanation]: #tap-pipelines
146147

147148
While not the intended use of this proposal, [tap](https://crates.io/crates/tap) is a popular crate to allow more advanced pipeline operations.
148149

@@ -251,6 +252,8 @@ make the language more flexible such that match statements aren't a hindrance.
251252

252253
## Alternatives
253254

255+
### Postfix Macros
256+
254257
[postfix macros](https://github.com/rust-lang/rfcs/pull/2442) have been an idea for many years now. If they were to land, this feature
255258
could easily be implemented as a macro (bikeshedding on postfix macro syntax):
256259

@@ -269,6 +272,19 @@ macro match_! (
269272
However, after years of discussion and hundreds of thumbs-ups, it feels like we're
270273
still not close to agreeing on syntax or behaviour.
271274

275+
### Pipes
276+
277+
I've already mentioned [tap](#tap-pipelines) for how we can do prefix-in-postfix,
278+
so we could promote the use of `.pipe` instead. However, using the pipe method makes
279+
async awkward and control flow impossible.
280+
281+
Alternatively we could have a new builtin pipeline operator
282+
(e.g. `|>`<sup>[0]</sup> or `.let x {}`><sup>[1]</sup>)
283+
but this is brand new syntax and requires a whole new set of discussions.
284+
285+
[0]: https://internals.rust-lang.org/t/idea-operator-for-postfix-calls-to-macros-and-free-functions/7634
286+
[1]: https://internals.rust-lang.org/t/idea-postfix-let-as-basis-for-postfix-macros/12438
287+
272288
# Prior art
273289
[prior-art]: #prior-art
274290

@@ -293,4 +309,4 @@ usecases of match would cause more [subtle bugs](https://fasterthanli.me/article
293309
# Future possibilities
294310
[future-possibilities]: #future-possibilities
295311

296-
Eventually more operators could become postfix, such as `for_each`
312+
I can't think of anything related to match that could be improved in this area

0 commit comments

Comments
 (0)