u/DueExam6212

▲ 7 r/rust

tldr: link is https://crates.io/crates/flense

I’m writing a more sound meshoptimizer wrapper, and I needed a good way to adapt their pattern of taking positions and other mesh attributes as a triple of (pointer, length, offset) as a sort of extended slice type.

Then, last week, I saw a post on lobste.rs about grist_lens, and I realized I was sort of implementing a lens, but purpose rather than field oriented.

There’s a couple examples in the readme, but generally the idea is that you can define a `Field`, like “Position” or “Color” or “Velocity”, then write an implementation of `Adapter` to define where that field exists in your particular data type. Then, you can acquire a lens on that data type and split or join it with others, use slice lenses as iterators, and so on.

Also there’s probably some wild unsoundness in here, but I’ve done my best and my tests at least pass under miri.

reddit.com
u/DueExam6212 — 21 days ago