fable-compiler.github.io icon indicating copy to clipboard operation
fable-compiler.github.io copied to clipboard

How to import module in Rust?

Open ieviev opened this issue 8 months ago • 1 comments

Hi! i could not find a way to import modules to rust. Is there a way to do this?

Currently a workaround is to inject it into an outer attribute tag like:

[<Fable.Core.Rust.OuterAttr("allow(unused)]\nmod rust_glue;\nmod helpers;\n#[cfg",
                            [| "target_arch = \"wasm32\"" |])>]

which gives a result like this:

Image

ieviev avatar Apr 21 '25 14:04 ieviev

Currently the native Rust imports and bindings are not very user friendly, but something like this should work. Note the imports are wrapped in a dummy local function to make the result a bit less messy.

ncave avatar Apr 21 '25 16:04 ncave