greyblake / nutype

Rust newtype with guarantees πŸ‡ΊπŸ‡¦ πŸ¦€
MIT License
1.42k stars 23 forks source link

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

Closed Hosshii closed 5 months ago

Hosshii commented 5 months ago

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

Thanks!

greyblake commented 5 months ago

@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!