Skip to content

Commit 7c81e4e

Browse files
committed
Fix formatting logic in DataLoadingOptions
Beyond efficiency, the previous impl might not add a space if the there where duplicated options.
1 parent b9f6784 commit 7c81e4e

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/ast/helpers/stmt_data_loading.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,14 @@ impl fmt::Display for StageParamsObject {
103103
impl fmt::Display for DataLoadingOptions {
104104
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
105105
if !self.options.is_empty() {
106+
let mut first = false;
106107
for option in &self.options {
107-
write!(f, "{}", option)?;
108-
if !option.eq(self.options.last().unwrap()) {
109-
write!(f, " ")?;
108+
if !first {
109+
first = true;
110+
} else {
111+
f.write_str(" ")?;
110112
}
113+
write!(f, "{}", option)?;
111114
}
112115
}
113116
Ok(())

0 commit comments

Comments
 (0)