Skip to content

Commit

Permalink
Fix format
Browse files Browse the repository at this point in the history
  • Loading branch information
0x7fff5238100b committed Feb 19, 2023
1 parent 805ada9 commit 3e17eda
Showing 1 changed file with 42 additions and 32 deletions.
74 changes: 42 additions & 32 deletions src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,20 +290,25 @@ impl<'a> Context<'a> {
}
.format();

let mut result = obj.clone();
result.insert(alias.to_string(), Value::String(output.unwrap()));

let tlen = tail.len();
if tlen == 0 {
self.results
.borrow_mut()
.push(Rc::new(Value::Object(result)));
} else {
self.stack.borrow_mut().push(StackItem::new(
Rc::new(Value::Object(result)),
tail,
self.stack.clone(),
));
match output {
Some(output) => {
let mut result = obj.clone();
result.insert(alias.to_string(), Value::String(output));

let tlen = tail.len();
if tlen == 0 {
self.results
.borrow_mut()
.push(Rc::new(Value::Object(result)));
} else {
self.stack.borrow_mut().push(StackItem::new(
Rc::new(Value::Object(result)),
tail,
self.stack.clone(),
));
}
}
_ => {}
}
}
Value::Array(ref array) => {
Expand All @@ -321,26 +326,31 @@ impl<'a> Context<'a> {
}
.format();

let mut result = e.clone();
match result.as_object_mut() {
Some(ref mut handle) => {
handle.insert(
alias.to_string(),
Value::String(output.unwrap()),
);
match output {
Some(output) => {
let mut result = e.clone();
match result.as_object_mut() {
Some(ref mut handle) => {
handle.insert(
alias.to_string(),
Value::String(output),
);
}
_ => {}
};

let tlen = tail.len();
if tlen == 0 {
self.results.borrow_mut().push(Rc::new(result));
} else {
self.stack.borrow_mut().push(StackItem::new(
Rc::new(result),
tail,
self.stack.clone(),
));
}
}
_ => {}
};

let tlen = tail.len();
if tlen == 0 {
self.results.borrow_mut().push(Rc::new(result));
} else {
self.stack.borrow_mut().push(StackItem::new(
Rc::new(result),
tail,
self.stack.clone(),
));
}
}
}
Expand Down

0 comments on commit 3e17eda

Please sign in to comment.