Skip to content

Commit

Permalink
Add ImportObject maybe_with_namespace example
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark McCaskey committed Sep 25, 2019
1 parent cda35af commit 285c6be
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/runtime-core/src/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,14 @@ impl ImportObject {
}

/// 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>
where
Func: FnOnce(&(dyn LikeNamespace + Send)) -> Option<InnerRet>,
Expand Down

0 comments on commit 285c6be

Please sign in to comment.