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

Implement impl ... for ... (partial) #1895

Merged
merged 11 commits into from
Jun 3, 2024

Conversation

NobodyForNothing
Copy link

@NobodyForNothing NobodyForNothing commented Apr 21, 2024

Changes

Generates methods when implementing traits for structs.

Fixes #1894

Also Fixes a typo on the website.

Checklist

  • An issue to be fixed by this PR is listed above.
  • 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 (or fast) 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.

Copy link

welcome bot commented Apr 21, 2024

Hi! Thanks for opening this pull request! 😄

@NobodyForNothing NobodyForNothing marked this pull request as draft April 21, 2024 16:09
@fzyzcjy
Copy link
Owner

fzyzcjy commented Apr 21, 2024

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

@dbsxdbsx
Copy link
Contributor

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.

@fzyzcjy
Copy link
Owner

fzyzcjy commented Jun 3, 2024

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.

@fzyzcjy
Copy link
Owner

fzyzcjy commented Jun 3, 2024

@all-contributors please add @NobodyForNothing for code,doc

Copy link
Contributor

@fzyzcjy

I've put up a pull request to add @NobodyForNothing! 🎉

fzyzcjy and others added 3 commits June 3, 2024 16:56
… into impl-for

# Conflicts:
#	frb_codegen/src/library/codegen/generator/api_dart/spec_generator/function.rs
#	frb_codegen/src/library/codegen/parser/function_extractor.rs
#	frb_codegen/src/library/codegen/parser/function_parser/mod.rs
#	frb_codegen/src/library/codegen/parser/function_parser/output.rs
#	frb_example/gallery/lib/src/rust/frb_generated.dart
#	frb_example/gallery/rust/src/frb_generated.rs
@fzyzcjy fzyzcjy marked this pull request as ready for review June 3, 2024 09:02
@fzyzcjy fzyzcjy changed the base branch from master to feat/12137 June 3, 2024 09:03
@fzyzcjy fzyzcjy merged commit cc0aa84 into fzyzcjy:feat/12137 Jun 3, 2024
39 of 99 checks passed
Copy link

welcome bot commented Jun 3, 2024

Hi! Congrats on merging your first pull request! 🎉

@fzyzcjy fzyzcjy changed the title Implement impl ... for ... Implement impl ... for ... (partial) Jun 3, 2024
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

Successfully merging this pull request may close these issues.

impl ... for ... doesn't generate code
3 participants