Rust Devs Explain Infinite Types
it's basically doable with a type level fixed point combinator (to write the infinite type fn() -> fn() -> fn() -> fn() -> ... as Fix<|A| fn() -> A>; the type-level function from A to fn() -> A is a higher-kinded type, and I think there's ways to encode HKT's in terms of GATs. trait TypeFn { type Output<A>; } struct Fix<F: TypeFn> (<F as TypeFn>::Output<Fix<F>>>; fn FnArrow impl TypeFn for FnArrow { type Output<A> = fn() -> A; } fn retself() -> Fix<FnArrow> { Fix(retself as fn() -> Fix<FnArrow>) } fn main() { println!("{:x}", retself as usize); println!("{:x}", retself().0 as usize); println!("{:x}", retself().0().0 as usize); println!("{:x}", retself().0().0().0 as usize); println!("{:x}", retself().0().0().0().0 as usize); } rust devs be like ^
A Discord screenshot shows someone explaining an extremely abstract Rust type-level fixed-point combinator, followed by dense Rust code that recursively prints function pointers. The joke is that Rust developers casually discuss higher-kinded types and GATs before producing incomprehensible type machinery, so it is used as a reaction to overcomplicated Rust code or intensely technical programming discourse.
Discord chat screenshot / скриншот чата Discordprogrammer avatar / аватар программистаtext message / текстовое сообщениеRust code / код на Rustcode block / блок кодаmonospace text / моноширинный текстfunction / функцияtype signature / сигнатура типаcurly braces / фигурные скобкиdark interface / тёмный интерфейс
#rust#программирование#programming#разработка#development#код#code#разработчик#developer#типизация#typing#type systems#система типов#higher-kinded types#типы высшего порядка#gats#шаблоны#generics#обобщения#рекурсия#recursion#сложный код#complex code#технический юмор#technical humor#сарказм#sarcasm#reaction#реакция#screenshot#скриншот
- @gentoomemes / 9133 2024-02-02
- Type
- image
- Size
- 800×537 · 60.8 KiB
- Mood
- саркастичный, абсурдный
- Language
- en
- Added