summaryrefslogtreecommitdiff
path: root/src/dump_as_rust.cpp
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2016-08-19 10:27:38 +0800
committerJohn Hodge <tpg@mutabah.net>2016-08-19 10:27:38 +0800
commita3e8257c4f77f197c9be2dbae7aaddb81257abb2 (patch)
tree598c815b4e42041966e3a0834a118b9a7c56411f /src/dump_as_rust.cpp
parent64c957b03ede8b0af825b50e6e551c61444a3275 (diff)
downloadmrust-a3e8257c4f77f197c9be2dbae7aaddb81257abb2.tar.gz
Patterns - Support tuples with .. (fully)
Diffstat (limited to 'src/dump_as_rust.cpp')
-rw-r--r--src/dump_as_rust.cpp32
1 files changed, 12 insertions, 20 deletions
diff --git a/src/dump_as_rust.cpp b/src/dump_as_rust.cpp
index 1f51f317..3c3a215d 100644
--- a/src/dump_as_rust.cpp
+++ b/src/dump_as_rust.cpp
@@ -535,6 +535,7 @@ private:
void print_params(const AST::GenericParams& params);
void print_bounds(const AST::GenericParams& params);
+ void print_pattern_tuple(const AST::Pattern::TuplePat& v);
void print_pattern(const AST::Pattern& p, bool is_refutable);
void print_type(const TypeRef& t);
@@ -772,6 +773,15 @@ void RustPrinter::print_bounds(const AST::GenericParams& params)
}
}
+void RustPrinter::print_pattern_tuple(const AST::Pattern::TuplePat& v)
+{
+ m_os << v.start;
+ if( v.has_wildcard )
+ {
+ m_os << ".., ";
+ m_os << v.end;
+ }
+}
void RustPrinter::print_pattern(const AST::Pattern& p, bool is_refutable)
{
if( p.binding().is_valid() ) {
@@ -814,16 +824,7 @@ void RustPrinter::print_pattern(const AST::Pattern& p, bool is_refutable)
),
(StructTuple,
m_os << v.path << "(";
- if( v.tup_pat.glob_pos == ::AST::Pattern::TupleGlob::Start ) {
- m_os << ".., ";
- }
- for(const auto& sp : v.tup_pat.sub_patterns) {
- print_pattern(sp, is_refutable);
- m_os << ",";
- }
- if( v.tup_pat.glob_pos == ::AST::Pattern::TupleGlob::End ) {
- m_os << " ..";
- }
+ this->print_pattern_tuple(v.tup_pat);
m_os << ")";
),
(Struct, {
@@ -838,16 +839,7 @@ void RustPrinter::print_pattern(const AST::Pattern& p, bool is_refutable)
}),
(Tuple,
m_os << "(";
- if( v.glob_pos == ::AST::Pattern::TupleGlob::Start ) {
- m_os << ".., ";
- }
- for(const auto& sp : v.sub_patterns) {
- print_pattern(sp, is_refutable);
- m_os << ",";
- }
- if( v.glob_pos == ::AST::Pattern::TupleGlob::End ) {
- m_os << " ..";
- }
+ this->print_pattern_tuple(v);
m_os << ")";
),
(Slice,