4 ms·
Can you point me to the swift docs for that? I don't understand what you are trying to do. You can bind references to what you are matching with @name. You als
by kevincox 6y ago
Can you point me to the swift docs for that? I don't understand what you are trying to do.
You can bind references to what you are matching with @name. You also don't need to take ownership of a value. You can match on a reference to it with &.
However without understanding your example it is hard to say for sure.
- masklinn 6y ago> You can bind references to what you are matching with @name. Given what they're saying I assume they're trying to match both the entire value and the sub-values e.g. xs@(_:xs') in Haskell. Stable Rust currently lets you use at-patterns and perform assertions on the sub-pattern, but not match there. > You also don't need to take ownership of a value. You can match on a reference to it with &. `ref` is what you'd use in a pattern though, `&` would deref' a reference so usually it'd be to Copy a Copy type which is provided behind a ref'.
- kevincox 6y ago> match both the entire value and the sub-values I see. Yes, it appears to be either-or for now. > `ref` is what you'd use in a pattern though Not in the pattern, in the "argument". Like this: https://rust.godbolt.org/z/eT366s https://rust.godbolt.org/z/eT366s pub fn f(v: &Option<String>) { match &v { other => eprintln!("Doesn't move {:?}", other), } }