Awful Rust snippets for fun and profit
442 subscribers
49 photos
54 links
seen something awful and want to post it here? send it to @goldsteinq
Download Telegram
transmute generic arrays without losing size check
playground
for<'a> fn(&'a ()) is not an HRTB
playground
reference
rustc fails to infer resolution for associated const and insists on the incorrect answer even when the full type is known
playground
rustc issue
and the workaround
playground
🌚4
evaluation order differs for primitive types
playground
reference
🤯6😢3
from lib never-say-never
GitHub
4🔥2
more fields ⇒ smaller type (nightly-only)
playground
GitHub issue comment
commented lines do not compile, the rest compiles
thanks to @wafflelapkin for correction!
playground
🤔5🔥3🥱1
how syn parses Rust literals (which are already parsed inside of proc_macro)
AFAIK there’s no better way to do it

syn code
internal representation of a Literal
IRLO thread
reversal of control to prevent boxing in object-safe traits
playground
type-erased generic outparams
playground
kinda obvious in retrospect
playground
there’s one deref missing and the whole Box gets coerced to dyn Any
🤯2
std::mem::uninitialized() initializes memory
playground
core library code
rules for temporary lifetime extension are syntactic, not semantic
playground
about temporary lifetimes
🥴14
you can just fabricate a vtable in Rust. no one can stop you.

playground

(that’s obviously UB tho)
👾9🤡1
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 usage of the word “Rust” in names of any projects, including non-commercial. (they also banned a bunch of stuff like modifying Rust logo and selling Rust merch).

that’s kinda awful. if you also find this policy kinda awful, please, express your disagreement in the feedback form. as far as I understand, it would be open for a week.

sorry for offtop & pinning, I hope that won’t happen again.
🤬28