mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-08 13:48:26 +00:00
Changed module set_name to return a boolean
This commit is contained in:
@@ -297,10 +297,9 @@ impl Module {
|
|||||||
/// Sets the name of the current module.
|
/// Sets the name of the current module.
|
||||||
/// This is normally useful for stacktraces and debugging.
|
/// This is normally useful for stacktraces and debugging.
|
||||||
///
|
///
|
||||||
/// ## Important
|
/// It will return `true` if the module name was changed successfully,
|
||||||
///
|
/// and return `false` otherwise (in case the module is already
|
||||||
/// If the module is already insantiated, setting a name will have
|
/// instantiated).
|
||||||
/// no effects (it will silently fail).
|
|
||||||
///
|
///
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
@@ -316,12 +315,14 @@ impl Module {
|
|||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
pub fn set_name(&mut self, name: &str) {
|
pub fn set_name(&mut self, name: &str) -> bool {
|
||||||
Arc::get_mut(&mut self.artifact)
|
Arc::get_mut(&mut self.artifact)
|
||||||
.and_then(|artifact| artifact.module_mut())
|
.and_then(|artifact| artifact.module_mut())
|
||||||
.map(|mut module_info| {
|
.map(|mut module_info| {
|
||||||
module_info.name = Some(name.to_string());
|
module_info.name = Some(name.to_string());
|
||||||
});
|
true
|
||||||
|
})
|
||||||
|
.unwrap_or(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns an iterator over the imported types in the Module.
|
/// Returns an iterator over the imported types in the Module.
|
||||||
|
|||||||
Reference in New Issue
Block a user