Make conversions to wasmtime::Result postfix-friendly (#10082)

This PR refactors the conversions to `wasmtime::Result` to use a trait
so that we can perform the conversions in a postfix-friendly way.

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2024-04-02 11:38:15 -04:00 committed by GitHub
parent c62239e9f0
commit a1cb6772bf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 59 additions and 59 deletions

View file

@ -119,3 +119,13 @@ impl Extension {
}
}
}
trait ToWasmtimeResult<T> {
fn to_wasmtime_result(self) -> wasmtime::Result<Result<T, String>>;
}
impl<T> ToWasmtimeResult<T> for Result<T> {
fn to_wasmtime_result(self) -> wasmtime::Result<Result<T, String>> {
Ok(self.map_err(|error| error.to_string()))
}
}