Skip to content

fix: use String class for imported interface modules#1443

Merged
dOrgJelli merged 2 commits into
origin-devfrom
wasm-rust-use-string-in-interface
Dec 13, 2022
Merged

fix: use String class for imported interface modules#1443
dOrgJelli merged 2 commits into
origin-devfrom
wasm-rust-use-string-in-interface

Conversation

@dOrgJelli
Copy link
Copy Markdown
Contributor

Using a lifetime for the interface module became quite cumbersome when working on the ethereum wrapper. This is because when an object w/ an internal lifetime is used, that lifetime must be annotated upward in the definition hierarchy. This causes a very unpleasant developer experience where you must annotate a lot of types with the <'a> lifetime.

For example, please consider the following code:

pub fn get_interface() -> InterfaceModule<'a> {
    let impls = Interface::get_implementations();
    IProviderModule::new(impls[0].as_str())
}

struct SomeObject<'a> {
  interface_module: InterfaceModule<'a>;
}

impl SomeObject<'a> {
  ...
}

fn function<'a>(arg: &InterfaceModule<'a>) -> void {
  ...
}

The use-case that shined light on this: https://github.com/polywrap/ethereum/blob/main/wrapper/src/polywrap_provider/iprovider.rs

Changing the imported interface to use the String class is much more ergonomic.

@dOrgJelli dOrgJelli merged commit e067906 into origin-dev Dec 13, 2022
@dOrgJelli dOrgJelli deleted the wasm-rust-use-string-in-interface branch April 10, 2023 17:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants