Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does rnet work with generics #7

Open
mercurial-moon opened this issue Aug 17, 2024 · 2 comments
Open

Does rnet work with generics #7

mercurial-moon opened this issue Aug 17, 2024 · 2 comments

Comments

@mercurial-moon
Copy link

Hi I'm trying to use rnet for this library https://github.com/lukaslueg/railroad which makes heavy use of generics
when I add the Net tag to a struct like so

#[derive(Debug, Clone, Net)]
pub struct Link<N> {
    inner: N,
    uri: String,
    target: Option<LinkTarget>,
    attributes: HashMap<String, String>,
}

it gives error like

error[E0412]: cannot find type N in this scope
--> src\lib.rs:290:12
|
290 | inner: N,
| ^ not found in this scope

do I need to configure rnet for use with generics?

@Diggsey
Copy link
Owner

Diggsey commented Aug 17, 2024

You cannot expose generics through rnet (or indeed any Rust <=> non-Rust interop mechanism) since Rust generics must be instantiated with known types are compile time, whereas in .net, generics are instantiated at runtime.

@mercurial-moon
Copy link
Author

Is there any workaround or alternative way where I can get this done, I researched around and people suggested using macros to create wrapper functions.
Like here
https://stackoverflow.com/questions/77742660/how-can-i-export-a-generic-rust-function-to-a-c-header

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

No branches or pull requests

2 participants