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

feat(opaque-debug): support generics #1053

Merged
merged 1 commit into from
Mar 1, 2024

Conversation

sinui0
Copy link
Contributor

@sinui0 sinui0 commented Feb 26, 2024

This PR adds support for opaque debug impls on structs with generics. It does not support structs with trait bounds as working with them using macro_rules! is not possible as far as I can tell.

It also wasn't obvious how to avoid exporting the format_params macro which is required to build the format template without a trailing comma eg Foo<T, U, V,> { ... }.

@newpavlov
Copy link
Member

newpavlov commented Feb 28, 2024

This looks fine on the first glance, but note that opaque-debug is essentially deprecated and not used in modern versions of RustCrypto crates. If this change is not needed for one of your projects, I think we can leave everything as-is.

@sinui0
Copy link
Contributor Author

sinui0 commented Feb 28, 2024

Thanks for taking a look. I wasn't aware that its heading towards deprecation. Would you mind pointing me to any discussion around that, or just dropping the gist of why here? I do use this in some projects but would be happy to close this and use an alternative.

@newpavlov
Copy link
Member

We had some complaints about number of dependencies which our crates pull (despite that the pulled crates are part of the same org...) and we decided that pulling a whole crate to save in most cases just 4 lines of code is usually not worth the trouble.

I do use this in some projects

In this case I think we can cut a new release.

@sinui0
Copy link
Contributor Author

sinui0 commented Feb 28, 2024

I see, thanks!

Re-looking at this PR, in particular the use of core::any::type_name I've just realized that in some cases it will write out the entire path of a type parameter. This could introduce a lot of noise. Instead I could trim to just the last element in the path based on the :: separator. But I can also see the case for wanting the full path. Thoughts?

@newpavlov
Copy link
Member

I could trim to just the last element in the path based on the :: separator

But generic parameter may contain its own generic parameters, which will not be trimmed with a naive approach. :) I am fine with either option with a slight preference of using output core::any::type_name as-is, because it's a more straightforward and simple solution.

@sinui0
Copy link
Contributor Author

sinui0 commented Feb 28, 2024

Hmm right, good call.

it's a more straightforward and simple solution.

Agreed. Best to avoid adding in String allocations and processing.

@newpavlov newpavlov merged commit 6918595 into RustCrypto:master Mar 1, 2024
9 checks passed
@sinui0 sinui0 deleted the feat/opaque-debug-generics branch March 12, 2024 17:34
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.

2 participants