diff src/ast_dump.rs @ 64:53817b39f139

Add FunctionDef.decorator_list support.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Mon, 13 Jun 2016 01:18:48 +0100
parents 5df52b40fe54
children ce5e27a3f277
line wrap: on
line diff
--- a/src/ast_dump.rs
+++ b/src/ast_dump.rs
@@ -227,7 +227,15 @@ impl stmt {
         match self.clone() {
             stmt::ClassDef(name, bases, keywords, body, decorator_list) => format!("{}class {}({}):\n{}", current_indent, name, vec_to_strings_vec(bases).join(", "), statements_to_string(indent, body)),
             stmt::FunctionDef(name, arguments, body, decorator_list, returns) => {
-                format!("{}def {}({}){}:\n{}",
+                format!("{}{}def {}({}){}:\n{}",
+                    {
+                        let decorators = vec_to_strings_vec(decorator_list);
+                        if decorators.is_empty() {
+                            String::new()
+                        } else {
+                            format!("{}@{}\n", current_indent, decorators.join(format!("\n{}@", current_indent).as_str()))
+                        }
+                    },
                     current_indent,
                     name,
                     arguments.to_string(),