Telegram Group Search
a slightly more fun slash cursed variation on a standard “enum-instead-of-bool” trick

playground
don’t use booleans — an explanation on why would you even want that

thanks to @Ddystopia_0 for inspiring this one!
parsing sequences (like dates or version strings) by matching on part index

playground
original example

thanks to @kanashimia for suggesting this one!
1.80 now warns on #[cfg(skip)], so here’s a workaround

playground
release notes about the warning

(also yay 300 subscribers!)
wrote down some thoughts about error handling, specifically a pattern that I call “progress pattern” (probably it has another name somewhere, but I’m not aware of it)
https://github.com/GoldsteinE/gh-blog/blob/master/error_progress/README.md
thanks to @meowaffle for reviewing this!

(btw, are y’all ok with breaking the format like this sometimes?)
iex by @purplesyringa automatically adds its attribute to the docs by injecting a <style> tag

code link
mixed-site hygiene might be surprising

original blogpost (read it, it’s cool!)
playground

thanks to @alexpyattaev for suggesting this!
cyclic associated types are okay under lazy normalization / next solver
(you need ?Sized though, otherwise it tries to prove Assoc: Sized and fails)

godbolt
tracking issue
macros can close over their environment, “breaking” hygiene

playground

I’d like to give a link to documentation here, but I don’t think this is actually documented anywhere? neither reference nor TLBORM mention it as far as I can see

UPD: ferrocene specification
Awful Rust snippets for fun and profit
so, a quick PSA moment The Rust Foundation (not to be confused with The Rust Project, who actually develop Rust) is currently planning to put up trademark policies that are so restrictive that this channel would be affected. essentially, they want to prohibit…
I’m sorry, but we seemingly need to do the same exact thing again
the new draft is somewhat better, but it still has at least two issues:
— it requires explicit approval to host events that are not free to attend, which includes even non-commercial events, since renting a venue isn’t actually free
— its wording around modified versions prohibits forking the compiler to send a PR, since you’re publicly distributing a modified version under the trademarked name

announces:
https://blog.rust-lang.org/2024/11/06/trademark-update.html
https://foundation.rust-lang.org/news/rust-trademark-policy-updates/

policy draft:
https://drive.google.com/file/d/1hjTx11Fb-4W7RQLmp3R8BLDACc7zxIpG/view?usp=sharing

feedback form:
https://docs.google.com/forms/d/e/1FAIpQLSeU1Ocopa0v9UZn_ZSTkKQM7gqZIrt63lCFz-xtogcFHMtkAg/viewform?usp=sf_link

please, read the policy and use the form to file your concerns if you have any. (please, don’t send my concerns without reading the policy yourself, that’s just spam)
Awful Rust snippets for fun and profit pinned «I’m sorry, but we seemingly need to do the same exact thing again the new draft is somewhat better, but it still has at least two issues: — it requires explicit approval to host events that are not free to attend, which includes even non-commercial events…»
inherent method resolution doesn’t use i32 fallback on conflict, but trait method resolution does

playground
(I don’t think this is documented anywhere, but feel free to correct me)

thanks to @Kolsky for suggesting this!
Awful Rust snippets for fun and profit
inherent method resolution doesn’t use i32 fallback on conflict, but trait method resolution does playground (I don’t think this is documented anywhere, but feel free to correct me) thanks to @Kolsky for suggesting this!
I think the reason is that basically .bar() is always the same method, so we can resolve it without needing to infer the type and then default the type later, but .foo() are two different methods and we need to know the type to choose between them
Awful Rust snippets for fun and profit
notably, this does not compile playground
the problem is that dbg!() expands to something like
match 42 { tmp => ..., }

where tmp now parses as a constant pattern instead of a variable binding
increment a counter and get its value in a single expr
playground

thanks to @Kolsky and @feedable for showing me this!
2025/02/21 12:19:05
Back to Top
HTML Embed Code: