dtolnay/typetag

Could the tag optionally come from a constant instead of a string literal?

rukai opened this issue · 1 comments

I can see that the name string literal is used in a function call here:


So I think typetag could additionally support the user specifying the name as a constant by specifying the constant instead of a string literal:

const CONSTANT: &str = "some name";
#[typetag::serde(name = CONSTANT)]
impl Foo for Bar { }

This would allow the user to reuse the tag name in other locations.

Does that sound reasonable to you?

Yes, I would accept a PR for this.