mirror of
https://github.com/fluencelabs/wasmer
synced 2025-06-25 06:31:32 +00:00
Add ImportObject maybe_with_namespace
example
This commit is contained in:
@ -6,6 +6,7 @@ Blocks of changes will separated by version increments.
|
|||||||
|
|
||||||
## **[Unreleased]**
|
## **[Unreleased]**
|
||||||
|
|
||||||
|
- [#833](https://github.com/wasmerio/wasmer/pull/833) Add doc example of using ImportObject's new `maybe_with_namespace` method
|
||||||
- [#832](https://github.com/wasmerio/wasmer/pull/832) Delete unused runtime ABI
|
- [#832](https://github.com/wasmerio/wasmer/pull/832) Delete unused runtime ABI
|
||||||
- [#809](https://github.com/wasmerio/wasmer/pull/809) Fix bugs leading to panics in `LocalBacking`.
|
- [#809](https://github.com/wasmerio/wasmer/pull/809) Fix bugs leading to panics in `LocalBacking`.
|
||||||
- [#822](https://github.com/wasmerio/wasmer/pull/822) Update Cranelift fork version to `0.43.1`
|
- [#822](https://github.com/wasmerio/wasmer/pull/822) Update Cranelift fork version to `0.43.1`
|
||||||
|
@ -124,6 +124,14 @@ impl ImportObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// The same as `with_namespace` but takes a function that may fail
|
/// The same as `with_namespace` but takes a function that may fail
|
||||||
|
/// # Usage:
|
||||||
|
/// ```
|
||||||
|
/// # use wasmer_runtime_core::import::{ImportObject, LikeNamespace};
|
||||||
|
/// # use wasmer_runtime_core::export::Export;
|
||||||
|
/// fn get_export(imports: &ImportObject, namespace: &str, name: &str) -> Option<Export> {
|
||||||
|
/// imports.maybe_with_namespace(namespace, |ns| ns.get_export(name))
|
||||||
|
/// }
|
||||||
|
/// ```
|
||||||
pub fn maybe_with_namespace<Func, InnerRet>(&self, namespace: &str, f: Func) -> Option<InnerRet>
|
pub fn maybe_with_namespace<Func, InnerRet>(&self, namespace: &str, f: Func) -> Option<InnerRet>
|
||||||
where
|
where
|
||||||
Func: FnOnce(&(dyn LikeNamespace + Send)) -> Option<InnerRet>,
|
Func: FnOnce(&(dyn LikeNamespace + Send)) -> Option<InnerRet>,
|
||||||
|
Reference in New Issue
Block a user