Crates.io | mutification_derive |
lib.rs | mutification_derive |
version | 0.3.0 |
source | src |
created_at | 2024-07-07 02:40:17.291916 |
updated_at | 2024-07-07 02:40:17.291916 |
description | Convert immutable reference to mutable reference. |
homepage | |
repository | https://github.com/Bruce0203/mutification |
max_upload_size | |
id | 1294493 |
size | 2,947 |
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";
}