review comments

This commit is contained in:
Josh Mcguigan 2020-03-23 05:19:09 -07:00
parent 2afccbe477
commit bc48c9d511
2 changed files with 114 additions and 17 deletions

View file

@ -136,8 +136,13 @@ pub fn placeholder_pat() -> ast::PlaceholderPat {
}
}
/// Creates a tuple of patterns from an interator of patterns.
///
/// Invariant: `pats` must be length > 1
///
/// FIXME handle `pats` length == 1
pub fn tuple_pat(pats: impl IntoIterator<Item = ast::Pat>) -> ast::TuplePat {
let pats_str = pats.into_iter().map(|p| p.syntax().to_string()).join(", ");
let pats_str = pats.into_iter().map(|p| p.to_string()).join(", ");
return from_text(&format!("({})", pats_str));
fn from_text(text: &str) -> ast::TuplePat {