flutter_rust_bridge
flutter_rust_bridge copied to clipboard
Implement `impl ... for ...`
Changes
Generates methods when implementing traits for structs.
Fixes #1894
Also Fixes a typo on the website.
Checklist
- [X] An issue to be fixed by this PR is listed above.
- [X] New tests are added to ensure new features are working. Please refer to this page to see how to add a test.
- [ ]
./frb_internal precommit --mode slow
(orfast
) is run (it internal runs code generator, does auto formatting, etc). - [ ] If this PR adds/changes features, documentations (in the
./website
folder) are updated. - [ ] CI is passing. Please refer to this page to see how to solve a failed CI.
Running ./frb_internal precommit --mode slow
locally always results in compilation errors/panics and changes a bunch of tracked files, even on the master branch. It would be great if someone could help me resolve this.
I'm also unsure how to use twin tests and left that part out.
Hi! Thanks for opening this pull request! :smile:
Running ./frb_internal precommit --mode slow locally always results in compilation errors/panics and changes a bunch of tracked files, even on the master branch. It would be great if someone could help me resolve this.
Then maybe ./frb_internal generate-internal-frb-example-pure-dart ; ./frb_internal precommit-generate
I'm also unsure how to use twin tests and left that part out.
It is auto generated (by commands above), no worries
Hopefully, this feature could be achieved soon.
In my case, there is an enum like this:
#[derive(Debug)]
pub enum ProxyNodeEnum {
Trojan(TrojanNode),
VMess(VMessNode),
VLESS(VLessNode),
}
impl ProxyNode for ProxyNodeEnum {
....
fn hostname(&self) -> &str {
match self {
ProxyNodeEnum::Trojan(node) => &node.hostname,
ProxyNodeEnum::VMess(node) => &node.host,
ProxyNodeEnum::VLESS(node) => &node.hostname,
}
}
fn port(&self) -> u16 {
match self {
ProxyNodeEnum::Trojan(node) => node.port,
ProxyNodeEnum::VMess(node) => node.port,
ProxyNodeEnum::VLESS(node) => node.port,
}
}
}
and there is an API return Vec<ProxyNodeEnum>
, and port()
and hostname()
is required to invoke in Dart.
This is needed when implementing auto scanning of external types, thus I will continue on it.
I will merge to feat/12137 and continue there.
@all-contributors please add @NobodyForNothing for code,doc
Hi! Congrats on merging your first pull request! :tada:
@fzyzcjy thank you for continuing this, I got a bit overwhelmed with the codebase and kinda forgot about this tbh.
A fair warning: Be careful when using this code. At this stage this was primarily me trying to understand the necessary changes and by no means a production ready implementation.
No worries, I made some necessary changes, and there are CI and thousands of tests to protect us as well!