chumsky icon indicating copy to clipboard operation
chumsky copied to clipboard

Consider renaming Seq::contains

Open Lilith-In-Starlight opened this issue 8 months ago • 2 comments

This function is identically named to the standard library's contains method for strings and arrays. The fact that this trait method also operates on those types and returns the same type (bool) makes it difficult to know when you're accidentally using this method instead of the standard library's methods, leading to issues that are difficult to debug if one isn't aware that this sort of method lookup issues can happen at all.

The issues caused by this particular problem are very difficult to recognize because in half of the cases, they successfully compile without any additional warnings.

Changing the name would make the method less risky in that regard.

Lilith-In-Starlight avatar May 16 '25 20:05 Lilith-In-Starlight

I agree, and am very happy to accept a change for this!

zesterer avatar May 18 '25 20:05 zesterer

The simple, if perhaps lazy alternative is to just rename it to something like seq_contains.

I can't really suggest a "real" solution though, I've never intentionally used the Seq trait

Lilith-In-Starlight avatar May 19 '25 18:05 Lilith-In-Starlight