IssueRaiser

Possible alternative to tilde/`?` using bound-like syntax

## Opinion I stumbled upon this repo as a complete outsider, and one of the things that stood out to me was the syntax. Taking an example from the book: ```rust ~async fn async_find<I>( iter: impl ~async Iterator<Item = I>, closure: impl ~async FnMut(&I) -> bool, ) -> Option<I> ``` Or (I think) its equivilant `where` ```rust ~async fn try async_find<It, Cl, I>(iter: It, closure: It) -> Option<I> where: It: ~async Iterator<Item = I>, Cl: ~async FnMut(&I) -> bool ``` I find it a bit difficult to read: - To somebody new to the syntax, there's nothing that really indicates the "asyncness" of the function is related to the asyncness of the iterator and closure. - `~` is a destructor in c++, bitwise NOT in C and some others, and used to be a heap operator in former Rust. Its usage for "if and only if" relationships is foreign to me and not super intuitive (maybe some other languages use something similar, I'm not aware) - `~` on its own is kind of a weird character, it's the same width as a letter but sort of visually floats. So it means that if some functions on a page are `~async` and some aren't, the `fn` keywords misalign just enough to be mildly annoying: ```rust async fn foo(F: impl async Iterator) ... ~async fn bar(F: impl ~async Iterator) ... async fn some_other_foo(F: impl async Iterator) ... ``` The last thing is a very subjective visual nitpicks, but I think in general this syntax has a potential to get a bit messy (are combinations like `~cons

Posted by tgross35 on Feb 1, 2023, 10:19 PM

Tags

Related issues

Raise real-world problems, find people facing the same issue, and discuss solutions.2,500 issues0 comments

ux (Other)

Possible alternative to tilde/`?` using bound-like syntax

tgross35Feb 1, 2023, 10:19 PM

## Opinion I stumbled upon this repo as a complete outsider, and one of the things that stood out to me was the syntax. Taking an example from the book: ```rust ~async fn async_find<I>( iter: impl ~async Iterator<Item = I>, closure: impl ~async FnMut(&I) -> bool, ) -> Option<I> ``` Or (I think) its equivilant `where` ```rust ~async fn try async_find<It, Cl, I>(iter: It, closure: It) -> Option<I> where: It: ~async Iterator<Item = I>, Cl: ~async FnMut(&I) -> bool ``` I find it a bit difficult to read: - To somebody new to the syntax, there's nothing that really indicates the "asyncness" of the function is related to the asyncness of the iterator and closure. - `~` is a destructor in c++, bitwise NOT in C and some others, and used to be a heap operator in former Rust. Its usage for "if and only if" relationships is foreign to me and not super intuitive (maybe some other languages use something similar, I'm not aware) - `~` on its own is kind of a weird character, it's the same width as a letter but sort of visually floats. So it means that if some functions on a page are `~async` and some aren't, the `fn` keywords misalign just enough to be mildly annoying: ```rust async fn foo(F: impl async Iterator) ... ~async fn bar(F: impl ~async Iterator) ... async fn some_other_foo(F: impl async Iterator) ... ``` The last thing is a very subjective visual nitpicks, but I think in general this syntax has a potential to get a bit messy (are combinations like `~cons

Comments (0)

No comments yet. Start the discussion.

Comment on this issue