RustPython/Parser

Implement `PartialEq<Builtin> for str/String`

MichaReiser opened this issue · 3 comments

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

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?

Isn't PartialEq 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`

Thank you! I got it.