Closed asmello closed 2 months ago
@chanced no urgency, but I think this is ready for a look when you have time.
@asmello, dude, you're awesome. This is so much cleaner than anything I would have produced.
I just realized I forgot to squash your last PR. Ah well.
I just realized I forgot to squash your last PR. Ah well.
There's always git rebase -i
😂
Ah, before I forget, one note since you mentioned you considered OnceCell
— I assume that was so we could memoize the decoded
value if it ever gets read. I don't think it's a bad idea, but I also think the Token
type is a bit of an ephemeral type; people will typically produce it as part of iteration and either use it immediately or convert the decoded value to a String
for keeping it around long-term.
It was. That logic is solid. I'm happy with out it.
The idea was to have something like`
pub struct Token(Internal);
enum Internal<'p> {
Uncoded(Cow<'p, str>),
Encoded { decoded: OnceCell<String>, encoded: Cow<'p, str> }
}
This includes surprisingly few API changes. The main breaks come from the fact
Token
holds a (potentially non-static) lifetime now. I also remove several trait implementations and some methods, in favor of making the distinction between the encoded and decoded representations more explicit.