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

Correct way of expanding once and get code for each file separately #227

Open
fzyzcjy opened this issue May 28, 2024 · 0 comments
Open

Correct way of expanding once and get code for each file separately #227

fzyzcjy opened this issue May 28, 2024 · 0 comments

Comments

@fzyzcjy
Copy link

fzyzcjy commented May 28, 2024

Hi, thanks for the wonderful tool!

When working on https://github.com/fzyzcjy/flutter_rust_bridge, cargo expand is used to expand user source code. Currently, only one call is made, and later the modules of corresponding files are extracted hackily.

However, it seems not very trivial to correctly extract what code belongs to a file (module). For example, if we simply count matching brackets, then we will fail when the code contains something like let a = "{"; because that bracket does not match.

Cargo expand does support expanding a single item, which works great. However, it seems that the time to expand that single item is the same as expanding a whole crate. Since flutter_rust_bridge needs to scan all files of the crate, it will call cargo expand (e.g.) hundreds of times, which is super slow, so this approach may not be super ideal.

Therefore, I would appreciate it if I could know how to run cargo-expand once, and then get code for each file(module) separately?

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

1 participant