fzyzcjy / flutter_rust_bridge

Flutter/Dart <-> Rust binding generator, feature-rich, but seamless and simple.
https://fzyzcjy.github.io/flutter_rust_bridge/
MIT License
4.26k stars 300 forks source link

[Bug] Generic types fail #773

Closed FireAndIceFrog closed 1 year ago

FireAndIceFrog commented 2 years ago

Describe the bug

All generic types Ive tried setting up throw an error

`pub fn start(file_path: String) -> GenericType { GenericType { item: 1, } }

pub struct GenericType { pub item: U }`

Codegen logs with RUST_LOG=debug environment variable

flutter_rust_bridge_codegen --rust-input A:\Github\grid_processor\src\lib.rs --dart-output ./lib/native/api.dart
[2022-10-10T08:11:32Z WARN  lib_flutter_rust_bridge_codegen::source_graph] Skipping unresolvable module io (tried \\?\A:\Github\grid_processor\src\io.rs, \\?\A:\Github\grid_processor\src\io\mod.rs, \\?\A:\Github\grid_processor\src\bridge_generated\io.rs, \\?\A:\Github\grid_processor\src\bridge_generated\io\mod.rs, )
thread 'main' panicked at 'Failed to parse function output type `GenericType<i64>`', C:\Users\User\.cargo\registry\src\github.com-1ecc6299db9ec823\flutter_rust_bridge_codegen-1.48.1\src\parser\mod.rs:160:25
stack backtrace:
   0:     0x7ff76ad2c15f - <unknown>
   1:     0x7ff76ad4eaca - <unknown>
   2:     0x7ff76ad263c9 - <unknown>
   3:     0x7ff76ad2edfb - <unknown>
   4:     0x7ff76ad2ea7b - <unknown>
   5:     0x7ff76ad2f3a9 - <unknown>
   6:     0x7ff76ad2f2ad - <unknown>
   7:     0x7ff76ad2cd97 - <unknown>
   8:     0x7ff76ad2ef89 - <unknown>
   9:     0x7ff76ad6d465 - <unknown>
  10:     0x7ff76a803919 - <unknown>
  11:     0x7ff76a882e46 - <unknown>
  12:     0x7ff76a8018fd - <unknown>
  13:     0x7ff76a7e33f5 - <unknown>
  14:     0x7ff76a8051a5 - <unknown>
  15:     0x7ff76a7d6cbb - <unknown>
  16:     0x7ff76a7d83e6 - <unknown>
  17:     0x7ff76a7d13cc - <unknown>
  18:     0x7ff76ad1edf1 - <unknown>
  19:     0x7ff76a7d7257 - <unknown>
  20:     0x7ff76ad56278 - <unknown>
  21:     0x7ffdbfd47034 - BaseThreadInitThunk
  22:     0x7ffdbffe26a1 - RtlUserThreadStart

To Reproduce

use this code:

pub fn start(file_path: String) -> GenericType<i64> {
    GenericType {
        item: 1,
    }
}

pub struct GenericType<U> {
    pub item: U
}

Expected behavior

dart code gets generated instead of throwing error

Generated binding code

no code created

OS

windows

Version of flutter_rust_bridge_codegen

1.48.1

Flutter info

No response

Version of clang++

No response

Version of ffigen

7.0

Additional context

No response

welcome[bot] commented 2 years ago

Hi! Thanks for opening your first issue here! :smile:

fzyzcjy commented 2 years ago

Yes it does not support generic yet. But feel free to PR!

FireAndIceFrog commented 2 years ago

Id love to, but it seems quite complex! Any ideas where to start? I havent done much work on lexical analysis/transpiling :/

fzyzcjy commented 2 years ago
stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] commented 1 year ago

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new issue.