We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 06b1027 commit 7b506f9Copy full SHA for 7b506f9
src/body.rs
@@ -75,6 +75,27 @@ impl Generator for Body {
75
}
76
77
78
+impl<T: ToString> From<Vec<T>> for Body {
79
+ fn from(body: Vec<T>) -> Self {
80
+ let body = body
81
+ .iter()
82
+ .map(|line| line.to_string())
83
+ .collect::<Vec<String>>();
84
+
85
+ Self {
86
+ factory: Some(Box::new(move |indentation, level| {
87
+ let body = body.clone();
88
89
+ body.iter()
90
+ .map(|line| indentation.indent(&line.to_string(), level))
91
+ .collect::<Vec<String>>()
92
+ .join("\n")
93
+ })),
94
+ semicolon_for_empty: true,
95
+ }
96
97
+}
98
99
impl From<String> for Body {
100
fn from(body: String) -> Self {
101
Self {
0 commit comments