Skip to content

Commit 4eaec90

Browse files
committed
transpile: Make WithStmts::prepend_stmts and add_stmt into builder methods
1 parent 6049b1f commit 4eaec90

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

c2rust-transpile/src/translator/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3254,7 +3254,7 @@ impl<'c> Translation<'c> {
32543254

32553255
if is_explicit {
32563256
let stmts = self.compute_variable_array_sizes(ctx, ty.ctype)?;
3257-
val.prepend_stmts(stmts);
3257+
val = val.prepend_stmts(stmts);
32583258
}
32593259

32603260
// Shuffle Vector "function" builtins will add a cast to the output of the

c2rust-transpile/src/with_stmts.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,15 @@ impl<T> WithStmts<T> {
136136
self.is_unsafe
137137
}
138138

139-
pub fn add_stmt(&mut self, stmt: Stmt) {
139+
pub fn add_stmt(mut self, stmt: Stmt) -> Self {
140140
self.stmts.push(stmt);
141+
self
141142
}
142143

143-
pub fn prepend_stmts(&mut self, mut stmts: Vec<Stmt>) {
144+
pub fn prepend_stmts(mut self, mut stmts: Vec<Stmt>) -> Self {
144145
stmts.append(&mut self.stmts);
145146
self.stmts = stmts;
147+
self
146148
}
147149

148150
pub fn is_pure(&self) -> bool {

0 commit comments

Comments
 (0)