generic-mutability

Crates.iogeneric-mutability
lib.rsgeneric-mutability
version0.1.0
sourcesrc
created_at2024-06-22 15:07:01.851639
updated_at2024-06-22 15:07:01.851639
descriptionAllows the creation of APIs that are generic over mutability
homepage
repositoryhttps://github.com/fzs111/rust-generic-mutability/
max_upload_size
id1280503
size58,285
FZs (fzs111)

documentation

README

rust-generic-mutability

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!

Contributing

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.

Commit count: 62

cargo fmt