logoalt Hacker News

Torturing Rustc by Emulating HKTs

65 pointsby g0xA52A2Alast Saturday at 7:25 AM6 commentsview on HN

Comments

mmastractoday at 12:13 AM

I've been playing around with type mapping like this in a highly experimental crate. The ability to map, filter and reduce types is insanely powerful but it's tough to get ergonomic syntax.

https://docs.rs/tuplemagic/latest/tuplemagic/index.html

j-kriegeryesterday at 9:53 PM

I also hit a funny compiler end-of-the road last month when I wanted to try out generic_const_exprs for my RFC8366 implementation:

  pub struct VoucherDetails<C>
    where
      C: CapacityConfig,
      [(); C::SERIAL_NUMBER_MAX]:,
      [(); C::MANUFACTURER_PRIVATE_MAX]:,
      [(); C::IDEVID_ISSUER_MAX]:,
      // <imagine a dozen more properties here>
      [(); C::NONCE_B64_MAX]:,
  { ... }
The heavy const eval + trait resolution was too much even for my M2 Pro.
show 1 reply
cptrootyesterday at 9:18 PM

This was incredible, even as it rapidly outpaced my PL and mathematics knowledge.

show 2 replies