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

Use absolute path for Result in macro-generated code #146

Merged
merged 1 commit into from
Jun 15, 2024

Conversation

Hosshii
Copy link
Contributor

@Hosshii Hosshii commented Jun 14, 2024

Hi! Thanks for this useful software.

Description

This pull request addresses a compilation error that occurs when using the crate with a custom Result type alias and deriving certain traits such as Deserialize from serde. For example:

#[nutype(derive(Deserialize))]
struct Name(String);

struct MyError;
pub type Result<T> = std::result::Result<T, MyError>;

The error message was:

type alias takes 1 generic argument but 2 generic arguments were supplied
expected 1 generic argument

Changes

  • Updated macros to use the absolute path (e.g. ::core::result::Result) for Result.

Thanks!

@greyblake
Copy link
Owner

@Hosshii Thank you very much for your contribution!

Usually I try to use absolute path for everything generated by macros (because we don't know in which context they will end up), but here I've missed it.

Thanks!

@greyblake greyblake merged commit 34f571b into greyblake:master Jun 15, 2024
@Hosshii Hosshii deleted the absolute_path branch June 15, 2024 10:50
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