I'm happy to announce that I published the first version of generic-mutability
, which allows library authors to create APIs that are generic over mutability (e.g. unique vs shared references).
If you haven't heard of it, generic mutability allows one (among other things) to write a pair of functions of the form
fn get<'a>(&'a T, ...) -> &'a U
fn get_mut<'a>(&'a mut T, ...) -> &'a mut U
as a single function
fn get_gen<'a, M: Mutability>(GenRef<'a, M, T>, ...) -> GenRef<'a, M, U>
This crate provides a GenRef
type that makes this possible, with the long term goal of becoming a language feature one day.
It is still experimental, so breaking changes can still happen, but the implementation is complete and usable.
However, I feel like I reached the limit to where I could push this project alone, so I would like to ask for your feedback and help on the following things:
-
Review
-
unsafe
!The project uses (and requires) unsafe code. While I'm relatively sure that the core idea is sound, I need more eyeballs to make sure that all implementations are sound including all edge cases, too. (After reading a lot about
unsafe
, my experience is that there is always one more corner case that I didn't think of.) -
Documentation
Please ask me stuff that is unclear or difficult to understand, so I can improve the docs to make it more accessible.
-
API design
Is the API easily usable? Are there any improvements you can think of? What color should the bikeshed be? I'll create a few issues on GitHub about things I'd like to discuss, and feel free to create more.
-
Optimizations
All of the crate's functionality should be zero-cost, but it relies on compiler optimizations. I'm not sure if the compiler can actually optimize everything away.
-
-
Contribute
-
Tests, tests, tests!
I suck at writing tests. I wrote a few, but I feel like I would need a lot more! But I don't really know how to go about it. So if you'd write some tests (or help me write more), I'd greatly appreciate it!
-
std
interfaceTo make this crate easier to use, I'm planning to create a separate crate that contains extension traits, structs & functions that help this crate interface with
std
andcore
APIs better, where applicable. Once I created the other crate, I'm looking for contributions on this one too.
-