Parser icon indicating copy to clipboard operation
Parser copied to clipboard

Implement `PartialEq<Builtin> for str/String`

Open MichaReiser opened this issue 2 years ago • 3 comments

We should implement PartialEq<Builtin> for &str and PartialEq<Builtin> for String so that both ident == str and str == ident work.

MichaReiser avatar May 15 '23 07:05 MichaReiser

Isn't PartialEq<Identifier> for str enough? That looks &ident == str and str == &ident will work. Is str in the example is std::string::String?

youknowone avatar May 15 '23 07:05 youknowone

Isn't PartialEq<Identifier> for str enough?

I don't think it is. Implementing PartialEq<&str> for Identifier only gives you ident == str but not str == ident doc

Adding PartialEq for String is mainly a convenience. Rust also implements str == String, it would be nice if Identifiers allow String comparison too.

Is str in the example is std::string::String?

It's either a &str or std::string::String`

MichaReiser avatar May 15 '23 07:05 MichaReiser

Thank you! I got it.

youknowone avatar May 15 '23 07:05 youknowone