Fuel documentation fixes (#5343)

- `Store::add_fuel` documentation said it'd panic when the engine is
  not configured to have fuel, but it in fact returns an error[1].

- There was a typo in `Store::add_fuel`'s documentation (either either).
  I "fixed" the typo by rewording the section using the same wording
  as `Store::fuel_consumed` (_if fuel consumption is not enabled
  via..._)

[1]ff5abfd993/crates/wasmtime/src/store.rs (L1397-L1400)
This commit is contained in:
Jimmy Bourassa
2022-11-29 12:08:52 -05:00
committed by GitHub
parent ff5abfd993
commit 4312cabc4b

View File

@@ -766,10 +766,10 @@ impl<T> Store<T> {
/// Note that at this time when fuel is entirely consumed it will cause /// Note that at this time when fuel is entirely consumed it will cause
/// wasm to trap. More usages of fuel are planned for the future. /// wasm to trap. More usages of fuel are planned for the future.
/// ///
/// # Panics /// # Errors
/// ///
/// This function will panic if the store's [`Config`](crate::Config) did /// This function will return an error if fuel consumption is not enabled via
/// not have fuel consumption enabled. /// [`Config::consume_fuel`](crate::Config::consume_fuel).
pub fn add_fuel(&mut self, fuel: u64) -> Result<()> { pub fn add_fuel(&mut self, fuel: u64) -> Result<()> {
self.inner.add_fuel(fuel) self.inner.add_fuel(fuel)
} }
@@ -790,9 +790,9 @@ impl<T> Store<T> {
/// ///
/// # Errors /// # Errors
/// ///
/// This function will return an either either if fuel consumption via /// This function will return an error either if fuel consumption is not
/// [`Config`](crate::Config) is disabled or if `fuel` exceeds the amount /// enabled via [`Config::consume_fuel`](crate::Config::consume_fuel) or if
/// of remaining fuel within this store. /// `fuel` exceeds the amount of remaining fuel within this store.
pub fn consume_fuel(&mut self, fuel: u64) -> Result<u64> { pub fn consume_fuel(&mut self, fuel: u64) -> Result<u64> {
self.inner.consume_fuel(fuel) self.inner.consume_fuel(fuel)
} }