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

Only translate trait method when used #487

Open
Nadrieril opened this issue Dec 10, 2024 · 5 comments
Open

Only translate trait method when used #487

Nadrieril opened this issue Dec 10, 2024 · 5 comments
Assignees

Comments

@Nadrieril
Copy link
Member

Currently, whenever we translate a trait like Iterator, we translate the signature of its many dozen methods. We could instead start each trait without any methods and only translate each method when we encounter it in the code.

@Nadrieril Nadrieril self-assigned this Dec 10, 2024
@sonmarcho
Copy link
Member

I agree with this. Just a small request: it would be good to have an option to switch between the two behaviors (but this is probably what you had in mind).

@Nadrieril
Copy link
Member Author

Nadrieril commented Dec 11, 2024

I intend this to be part of the normal crate exploration behavior, therefore if you want to include all iterator methods and bodies you can use --include core::iter::Iterator. If you want just the method signatures, you can use --include core::iter::Iterator --opaque core::iter::Iterator::*.

@sonmarcho
Copy link
Member

I often use the current behavior to generate models for the backends: it's an easy of getting the trait declaration, method declarations and instance declarations for free. I'm perfectly fine if what you suggest becomes the new default behavior, but it would be good if we could use an option to re-activate the current behavior (should be simple right?).

@Nadrieril
Copy link
Member Author

When generating models you can just --include *, no? Eventually I want the name matcher to support item kinds and to adjust the recursive meaning of patterns, in which case the flag you want will also be equivalent to --include 'trait *'.

@sonmarcho
Copy link
Member

Following an offline discussion: the best solution so far is to have options which are actually sugar for --include of the proper pattern. This way we have a general mechanism to control which items get included or not and the implementation doesn't have to handle ad-hoc cases, while users have shortcuts which are easy to use for some common patterns.

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