RustPython / Parser

MIT License
67 stars 24 forks source link

Implement `PartialEq<Builtin> for str/String` #29

Open MichaReiser opened 1 year ago

MichaReiser commented 1 year ago

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

youknowone commented 1 year ago

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?

MichaReiser commented 1 year ago

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 orstd::string::String`

youknowone commented 1 year ago

Thank you! I got it.