ryo33 / enum_downcast

Safe downcasting for enums
3 stars 0 forks source link

Use fully qualified path for Results #2

Closed silvasch closed 3 months ago

silvasch commented 3 months ago

Hey!

This is an awesome crate.

However, I had one issue, specifically with this piece of code:

use enum_downcast::EnumDowncast;

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

#[derive(EnumDowncast)]
enum EnumWithDowncast {
    Player(i32),
    Enemy(String),
}

This causes compilation to fail, because the EnumDowncast derive macro contains Result (e. g. here) and gets overridden by the custom Result implementation.

This would probably be fixed by using the fully qualified path to Result in the enum_downcast_derive crate (Replace every Result<...> with std::result::Result<...>).

If you want, I can open a PR for this.

ryo33 commented 3 months ago

Thanks for your suggestion!

Yes, it should use a qualified path. And, sending a PR is appreciated! since this crate would love to support no_std, the fully qualified paths should be core::result::Result instead of std:: one.

silvasch commented 3 months ago

Great! I'll submit a PR sometime today.

silvasch commented 3 months ago

Implemented in 0.2.0