Here's a Rust puzzler for you: is there a way to promote a const to the type level, or another way to do the comparison `size_of::<A>() > size_of::<B>()` with type level numbers? I believe the answer is "no," but if it's "yes," it enables a very cool optimisation for im vectors.
-
Show this thread
-
Another day, another trivial use case for dependent types blocked by the sad reality that not all languages are Idris yet.
1 reply 4 retweets 38 likesShow this thread -
(And, yes, requiring A and B to both implement a trait with an associated type containing the size at the type level is indeed not practical.)
1 reply 0 retweets 4 likesShow this thread -
Yup, turns out you really don't need type level gymnastics after all to get here, just the target type itself, some consts and a few Dark Side powers. So much cleaner than what I thought I'd have to do. https://docs.rs/sized-chunks/0.3.0/src/sized_chunks/inline_array.rs.html#78 …
2 replies 0 retweets 4 likesShow this thread -
This lets me store a small number of elements directly on the stack with zero allocations for `im::Vector`, meaning that it's once again _faster_ than `Vec` when it's very, very small, but this time I don't waste any more of your stack space than strictly necessary to get there.
2 replies 0 retweets 13 likesShow this thread
Rust is designed to make mortals cry so that we may spark joy in production. I hate developing rust, I love it in production... allocation free rust is hard!
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.