Skip to content

Commit

Permalink
rune: Backport changes to Value::string_debug_with
Browse files Browse the repository at this point in the history
This ensures that we don't get an error on formatting a value without a debug protocol.

(fixes #747)
  • Loading branch information
VorpalBlade committed Jul 17, 2024
1 parent 63940d3 commit 952b5fb
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions crates/rune/src/runtime/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -495,11 +495,16 @@ impl Value {
vm_write!(f, "{:?}", value);
}
value => {
// reborrow f to avoid moving it
let result =
vm_try!(caller.call_protocol_fn(Protocol::STRING_DEBUG, value.clone(), (f,),));
caller.call_protocol_fn(Protocol::STRING_DEBUG, self.clone(), (&mut *f,));

vm_try!(<()>::from_value(result));
return VmResult::Ok(());
if let VmResult::Ok(result) = result {
vm_try!(<()>::from_value(result));
} else {
let type_info = vm_try!(value.type_info());
vm_write!(f, "<{} object at {:p}>", type_info, value);
}
}
};

Expand Down

0 comments on commit 952b5fb

Please sign in to comment.