mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-19 00:31:19 +00:00
Auto merge of #13978 - bvanjoi:array-match, r=Veykril
feat: array match fixed https://github.com/rust-lang/rust-analyzer/issues/13970
This commit is contained in:
commit
d46d012c38
3 changed files with 157 additions and 11 deletions
|
@ -520,6 +520,15 @@ pub fn literal_pat(lit: &str) -> ast::LiteralPat {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn slice_pat(pats: impl IntoIterator<Item = ast::Pat>) -> ast::SlicePat {
|
||||
let pats_str = pats.into_iter().join(", ");
|
||||
return from_text(&format!("[{pats_str}]"));
|
||||
|
||||
fn from_text(text: &str) -> ast::SlicePat {
|
||||
ast_from_text(&format!("fn f() {{ match () {{{text} => ()}} }}"))
|
||||
}
|
||||
}
|
||||
|
||||
/// Creates a tuple of patterns from an iterator of patterns.
|
||||
///
|
||||
/// Invariant: `pats` must be length > 0
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue