My ideas are not comprehensive enough. so the post is closed.
I am a beginner in Rust.
This writing style used to confuse me.
fn mutate_and_share(&mut self) -> &Self {}
I found it equivalent to this writing style.
fn mutate_and_share(self: &mut Self) -> &Self {}
I think this writing style is more reasonable.
// mut&T
fn mutate_and_share(self: mut&Self) -> &Self {}
// or a simpler way $T
fn mutate_and_share(self: $Self) -> &Self {
}
// If there are more modifications in the future
// My idea is not yet perfect.It seems like there is more confusion.
fn mutate_and_share(self: keyword $Self) -> &Self {
}
mut &Self already has meaning: a mutable instance of a &Self (though it is kind of confusing for it to be an actual self binding). Reformulating to u32, we have:
let mut k = &1_u32;
k = &2; // It can be updated to point to another `&u32`.
$Self
Why a new sigil? Rust already has the component bits well-defined and in wide-spread use such that seeing the individual bits makes more sense to me. I don't do Perl often, but deciphering the different sigils is always a pain when trying to fix some ancient Perl script.
This one idea wasn't one we're likely to run with, but the instinct to see things and consider changing them to better suit your purposes is a good instinct. You'll have better ideas in the future, to evolve things in compatible directions.