Skip to content
This repository has been archived by the owner on Feb 27, 2024. It is now read-only.

Don't require members of structs to also impl TypeName #10

Open
Boscop opened this issue Jul 5, 2019 · 5 comments
Open

Don't require members of structs to also impl TypeName #10

Boscop opened this issue Jul 5, 2019 · 5 comments

Comments

@Boscop
Copy link

Boscop commented Jul 5, 2019

image

It shouldn't be necessary for members to also impl TypeName.

@antiguru
Copy link
Member

antiguru commented Jul 5, 2019

IIRC, we don't require for generic types implementing TypeName that their generic parameters also implement TypeName. Could you provide a MWE so we can have a look?

What might happen is that somewhere a type name of a GetSessionData type is requested when K doesn't implement TypeName.

@Boscop
Copy link
Author

Boscop commented Jul 9, 2019

What might happen is that somewhere a type name of a GetSessionData type is requested when K doesn't implement TypeName.

@antiguru But that's what I mean, K shouldn't have to impl TypeName in order for GetSessionData to impl TypeName! Why is it required?

@antiguru
Copy link
Member

antiguru commented Jul 9, 2019

Currently, we include generic parameters in the type name, as they are effectively part of the type. Instead of using derive(TypeName), you could implement the TypeName trait yourself for GetSessionData. This implementation then doesn't need to have the requriement for K: TypeName.

@Boscop
Copy link
Author

Boscop commented Aug 20, 2019

@antiguru But why are you including generic parameters in the type name?

(I want to avoid having to manually implement TypeName.)

@gandro
Copy link
Member

gandro commented Aug 20, 2019

We have found it useful to differentiate between Vec<i32> and Vec<TcpStream>, which are two entirely different things. It is also the main reason we need a formatter, as we cannot return a static string.

In addition, I also wanted to be roughly compatible with std's type_name intrinsic (which will be stabilized soon, making this crate obsolete).

If you need type names without generic parameters, I recommend you use the named_type crate instead.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants