#reference #immutability #mutable #convert #complex #borrow #field

mutification

Convert immutable reference to mutable reference

3 releases (breaking)

0.3.0 Jul 7, 2024
0.2.0 Jul 7, 2024
0.1.0 Jul 7, 2024

#1027 in Algorithms

49 downloads per month

MIT license

3KB

mutification

Convert immutable reference to mutable reference. When creating a getter and setter as a trait to get a field from a structure in a complex gaming system, this is a crate that safely changes an immutable reference to a mutable reference so that you can bypass the Rust compiler rules where you can't borrow another field at the same time!

  • to_mut crate is more conventient than to-mut/to-mut-proc-macro.
  • Support generics.

example

fn test_to_mut(player: &Player) {
    player.to_mut().name = "Bruce";
}

Dependencies

~280–730KB
~17K SLoC