Crates.io | generic-mutability |
lib.rs | generic-mutability |
version | 0.1.0 |
source | src |
created_at | 2024-06-22 15:07:01.851639 |
updated_at | 2024-06-22 15:07:01.851639 |
description | Allows the creation of APIs that are generic over mutability |
homepage | |
repository | https://github.com/fzs111/rust-generic-mutability/ |
max_upload_size | |
id | 1280503 |
size | 58,285 |
This crate enables the creation of functions, methods, traits or even structs generic over mutability.
The main use case is allowing crates to write pairs of getter 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 project is currently in an experimental state. Breaking changes are expected before reaching 1.0.0
. You can start experimenting with it in your own projects. Any feedback is welcome!
If you can, please help with any of the following:
Review
unsafe
This crate relies on unsafe
to work.
documentation
If there is anything that is unclear, you can ask me or improve it yourself.
API design
Feel free to bikeshed some things and point out problems before this goes "production ready"!
Tests
This project doesn't have a lot of tests. If you can write some, I'd greatly appreciate it!
std
interface
We'll need to create extension traits and functions that make std
accessible to generic mutability.