alexcrichton opened PR #3352 from consume-fuel
to main
:
This can be useful for host functions that want to consume fuel to
reflect their relative cost. Additionally it's a relatively easy
addition to have and someone's asking for it!Closes #3315
<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
fitzgen submitted PR review.
fitzgen submitted PR review.
fitzgen created PR review comment:
Maybe saturating arithmetic is the right thing to do here instead of returning an error? Unsure.
I guess we could punt that saturate-or-not decision to the embedder since they can check
fuel_consumed
and compare it to the fuel added to clamp the amount of fuel to consume when calling this method. Might make sense to have afuel_remaining
method so they don't have to remember how much fuel was added and do that comparison themselves.
alexcrichton submitted PR review.
alexcrichton created PR review comment:
I figure this is something we'll probably tweak over time yeah. The precise interfaces here aren't exhasutively considered and bike-shedded, rather they're mostly just situation-solving feature requests as we get them. For now I figured you could get
fuel_remaining
withconsume_fuel(0)
, but we can always add another path if necessary in the future too.
alexcrichton merged PR #3352.
Last updated: Dec 23 2024 at 12:05 UTC