cargo-fix wasmi
This commit is contained in:
parent
1bf3cbe5d0
commit
925634c4a0
|
@ -114,11 +114,11 @@ pub trait HostError: 'static + ::core::fmt::Display + ::core::fmt::Debug + Send
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HostError {
|
impl dyn HostError {
|
||||||
/// Attempt to downcast this `HostError` to a concrete type by reference.
|
/// Attempt to downcast this `HostError` to a concrete type by reference.
|
||||||
pub fn downcast_ref<T: HostError>(&self) -> Option<&T> {
|
pub fn downcast_ref<T: HostError>(&self) -> Option<&T> {
|
||||||
if self.__private_get_type_id__() == TypeId::of::<T>() {
|
if self.__private_get_type_id__() == TypeId::of::<T>() {
|
||||||
unsafe { Some(&*(self as *const HostError as *const T)) }
|
unsafe { Some(&*(self as *const dyn HostError as *const T)) }
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
@ -128,7 +128,7 @@ impl HostError {
|
||||||
/// reference.
|
/// reference.
|
||||||
pub fn downcast_mut<T: HostError>(&mut self) -> Option<&mut T> {
|
pub fn downcast_mut<T: HostError>(&mut self) -> Option<&mut T> {
|
||||||
if self.__private_get_type_id__() == TypeId::of::<T>() {
|
if self.__private_get_type_id__() == TypeId::of::<T>() {
|
||||||
unsafe { Some(&mut *(self as *mut HostError as *mut T)) }
|
unsafe { Some(&mut *(self as *mut dyn HostError as *mut T)) }
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
@ -257,5 +257,5 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tests that `HostError` trait is object safe.
|
// Tests that `HostError` trait is object safe.
|
||||||
fn _host_error_is_object_safe(_: &HostError) {}
|
fn _host_error_is_object_safe(_: &dyn HostError) {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,7 +103,7 @@ pub trait ImportResolver {
|
||||||
/// [`ImportResolver`]: trait.ImportResolver.html
|
/// [`ImportResolver`]: trait.ImportResolver.html
|
||||||
/// [`ModuleImportResolver`]: trait.ModuleImportResolver.html
|
/// [`ModuleImportResolver`]: trait.ModuleImportResolver.html
|
||||||
pub struct ImportsBuilder<'a> {
|
pub struct ImportsBuilder<'a> {
|
||||||
modules: BTreeMap<String, &'a ModuleImportResolver>,
|
modules: BTreeMap<String, &'a dyn ModuleImportResolver>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Default for ImportsBuilder<'a> {
|
impl<'a> Default for ImportsBuilder<'a> {
|
||||||
|
@ -124,7 +124,7 @@ impl<'a> ImportsBuilder<'a> {
|
||||||
pub fn with_resolver<N: Into<String>>(
|
pub fn with_resolver<N: Into<String>>(
|
||||||
mut self,
|
mut self,
|
||||||
name: N,
|
name: N,
|
||||||
resolver: &'a ModuleImportResolver,
|
resolver: &'a dyn ModuleImportResolver,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
self.modules.insert(name.into(), resolver);
|
self.modules.insert(name.into(), resolver);
|
||||||
self
|
self
|
||||||
|
@ -133,11 +133,11 @@ impl<'a> ImportsBuilder<'a> {
|
||||||
/// Register an resolver by a name.
|
/// Register an resolver by a name.
|
||||||
///
|
///
|
||||||
/// Mutable borrowed version.
|
/// Mutable borrowed version.
|
||||||
pub fn push_resolver<N: Into<String>>(&mut self, name: N, resolver: &'a ModuleImportResolver) {
|
pub fn push_resolver<N: Into<String>>(&mut self, name: N, resolver: &'a dyn ModuleImportResolver) {
|
||||||
self.modules.insert(name.into(), resolver);
|
self.modules.insert(name.into(), resolver);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn resolver(&self, name: &str) -> Option<&ModuleImportResolver> {
|
fn resolver(&self, name: &str) -> Option<&dyn ModuleImportResolver> {
|
||||||
self.modules.get(name).cloned()
|
self.modules.get(name).cloned()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -239,7 +239,7 @@ pub enum TrapKind {
|
||||||
/// Typically returned from an implementation of [`Externals`].
|
/// Typically returned from an implementation of [`Externals`].
|
||||||
///
|
///
|
||||||
/// [`Externals`]: trait.Externals.html
|
/// [`Externals`]: trait.Externals.html
|
||||||
Host(Box<host::HostError>),
|
Host(Box<dyn host::HostError>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TrapKind {
|
impl TrapKind {
|
||||||
|
@ -273,7 +273,7 @@ pub enum Error {
|
||||||
/// Trap.
|
/// Trap.
|
||||||
Trap(Trap),
|
Trap(Trap),
|
||||||
/// Custom embedder error.
|
/// Custom embedder error.
|
||||||
Host(Box<host::HostError>),
|
Host(Box<dyn host::HostError>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Error {
|
impl Error {
|
||||||
|
@ -285,7 +285,7 @@ impl Error {
|
||||||
/// [`Host`]: enum.Error.html#variant.Host
|
/// [`Host`]: enum.Error.html#variant.Host
|
||||||
/// [`Trap`]: enum.Error.html#variant.Trap
|
/// [`Trap`]: enum.Error.html#variant.Trap
|
||||||
/// [`TrapKind::Host`]: enum.TrapKind.html#variant.Host
|
/// [`TrapKind::Host`]: enum.TrapKind.html#variant.Host
|
||||||
pub fn as_host_error(&self) -> Option<&host::HostError> {
|
pub fn as_host_error(&self) -> Option<&dyn host::HostError> {
|
||||||
match *self {
|
match *self {
|
||||||
Error::Host(ref host_err) => Some(&**host_err),
|
Error::Host(ref host_err) => Some(&**host_err),
|
||||||
Error::Trap(ref trap) => match *trap.kind() {
|
Error::Trap(ref trap) => match *trap.kind() {
|
||||||
|
|
Loading…
Reference in New Issue