News Score: Score the News, Sort the News, Rewrite the Headlines

Cursed Linear Types In Rust

Inspired by Jack Wrenn’s post on Undroppable Types in Rust, I set out to see if it’s possible to create types that must be used exactly once. From my understanding, those things are called linear types, but don’t quote me on that1. Let’s see if we can create a struct UseOnce<T> which enforces that an instance is used (or consumed) exactly once. It should be impossible to consume it more than once, and it should produce a compile error if it’s not consumed at all. The first part is trivial with d...

Read more at geo-ant.github.io

© News Score  score the news, sort the news, rewrite the headlines