Skip to content

Passing BindingResolveOptions#alias from js to rust with maintaining order #790

@hyf0

Description

@hyf0

pub struct BindingResolveOptions {
// FIXME: Using `HashMap<String, Vec<String>>` is wrong here. Rust's `HashMap` is not ordered, while JavaScript's `Object` is ordered.
// We should use tuple array instead of object.
pub alias: Option<HashMap<String, Vec<String>>>,

Possible solutions

Use Option<Vec<(String, Vec<String>)>>>

The problem is that NAPI-RS so far doesn't support tuples

Define a temporary struct like

pub struct AliasItem {
  pub name: String,
  pub paths: Vec<String>,
}

and write Option<Vec<AliasItem>>>.


I personally prefer using tuples on this case. However this requires discussing with NAPI-RS if this feature is really needed.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions