You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Lets say you want a reference to a variable in a pattern. You can't use & because that matches a reference, rather than creates one (and thus has the effect of dereferencing the object). For example, ...
Do you mean a) "Let's say you want to make a reference to an (ordinary) struct field using a pattern (effectively aliasing the field)", b) "Let's say you want to refer to a reference variable in a struct using a pattern (creating an additional reference to the object referred to by the field)" or c) something else?
Why would "matching a reference" have the effect of dereferencing the object? On the face of it, that is surprising behavior (unless it's to avoid a &&T (in which case I'd still have expected the dereference to yield the expected &T)). Maybe another sentence explaining why the dereference would be helpful?
The text was updated successfully, but these errors were encountered:
U007D
changed the title
Why would a reference dereference?
Docs: Why would a reference dereference?
Sep 22, 2016
U007D
changed the title
Docs: Why would a reference dereference?
Why would a reference dereference?
Sep 22, 2016
In Destructuring, you write
Do you mean a) "Let's say you want to make a reference to an (ordinary) struct field using a pattern (effectively aliasing the field)", b) "Let's say you want to refer to a reference variable in a struct using a pattern (creating an additional reference to the object referred to by the field)" or c) something else?
Why would "matching a reference" have the effect of dereferencing the object? On the face of it, that is surprising behavior (unless it's to avoid a &&T (in which case I'd still have expected the dereference to yield the expected &T)). Maybe another sentence explaining why the dereference would be helpful?
The text was updated successfully, but these errors were encountered: