Why &ref x cannot be extended?

⚓ Rust    📅 2025-11-26    👤 surdeus    👁️ 8      

surdeus

Reference says:

An extending pattern is either: An identifier pattern that binds by reference or mutable reference. ... So ref x, V(ref x) and [ref x, y] are all extending patterns, but x, &ref x and &(ref x,) are not.

I am wondering why these three patterns cannot be extended?

I know that 'x' is not a reference pattern and so does not need to be extended, because it owns it's value and no extension is needed.
But i can't understand why '&ref x' and &(ref x,) do not extend.

3 posts - 3 participants

Read full topic

🏷️ Rust_feed