Rust 是否可以在函数声明中用无可辩驳的模式来分解元组?

Rust 是否可以在函数声明中用无可辩驳的模式来分解元组?,rust,tuples,pattern-matching,destructuring,Rust,Tuples,Pattern Matching,Destructuring,我现在能做的就是 // this function accepts k,v fn foo( k: &str, v: u8 ) -> bool { true } 但我不能分解签名中的参数 // this function accepts (k,v) tuple fn bar( (k: &str, v: u8) // notice the parens ) -> bool { true } 有没有可能用无可辩驳的模式来分解元组?你要做的

我现在能做的就是

// this function accepts k,v
fn foo(
    k: &str, v: u8
) -> bool {
    true
}
但我不能分解签名中的参数

// this function accepts (k,v) tuple
fn bar(
    (k: &str, v: u8) // notice the parens
) -> bool {
    true
}

有没有可能用无可辩驳的模式来分解元组?

你要做的是键入整个元组,而不是其中的组件

// this function accepts (k,v) tuple
fn baz(
    (k, v): (&str, u8) // notice the parens
) -> bool {
    true
}

你要做的是键入整个元组,而不是其中的组件

// this function accepts (k,v) tuple
fn baz(
    (k, v): (&str, u8) // notice the parens
) -> bool {
    true
}
可能的重复可能的重复