Why Nostr? What is Njump?
2024-03-14 03:22:05

varx/tech on Nostr: Today's Rust learning: I've been doing this thing where I have a param `foo: &Bar` ...

Today's Rust learning:

I've been doing this thing where I have a param `foo: &Bar` and then I pass it to some function as `&foo` because I've superstitiously stuck & onto everything to make the compiler happy. Turns out this creates a double reference; that only works because the compiler is automatically dereferencing the first layer to make things match up. My `foo` is already a reference, so I can pass that reference.

This clears some things up. :-) I'm still missing something about borrowing, but I'll get there.

(Thanks to cargo-clippy for illuminating this!)
Author Public Key
npub13cavz8sul0get8lllzwszm7j5mq4n3ygpn60uqn54su99csl9wyqeu3sx0