ref stand for reference here? If so, why do we create another keyword instead of using the existing
I'm guessing you're talking about
static ref in this case is passed to a macro, it's not part of the language per se.
But why did they choose
static ref then?
ref in a pattern means "take a reference to the thing which I'm binding too, instead of moving it". In
lazy_static, you end up with something that derefs to the type in question / the value on the right hand side, so it's pretty similar.
Why is it a keyword? When you're destructuring or similar, you can't always just insert a
& on the right hand side, and putting a
& in your pattern on the left-hand side does the opposite what you want. (Hopefully the examples in the link above make this clear.)
Because, as @quinedot already mentioned, they do the opposite thing. This is because expressions and patterns are not the same, rather, they are duals to each other.
Your link appears to be broken. I'm guessing that you wanted to link to this:
Yes, you are right! Discourse doesn't seem to recognize URLs without an explicit protocol designation.
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.