modularml / mojo

The Mojo Programming Language
https://docs.modular.com/mojo
Other
21.91k stars 2.53k forks source link

[External] [stdlib] List.__contains__ #2667

Closed rd4com closed 4 weeks ago

rd4com commented 1 month ago

Hello, here is List.__contains__, The conformance is done by hand with constrained, _type_is_eq and rebind so that users can do:

var x = List[Int](1,2,3)
if 3 in x: print("ok")

If value would be T2, we would not be able to do it (this is the same PR as https://github.com/modularml/mojo/pull/2662 and https://github.com/modularml/mojo/pull/2665 , started over again)

helehex commented 4 weeks ago

Hey that's really awesome! I didn't know you could do that

rd4com commented 4 weeks ago

Hello @JoeLoser , glad you like it !

Your videos and the community stream helped a lot :partying_face:

I'm learning branch in order to do multiple PR at same time !

modularbot commented 4 weeks ago

✅🟣 This contribution has been merged 🟣✅

Your pull request has been merged to the internal upstream Mojo sources. It will be reflected here in the Mojo repository on the nightly branch during the next Mojo nightly release, typically within the next 24-48 hours.

We use Copybara to merge external contributions, click here to learn more.

modularbot commented 4 weeks ago

Landed in 97eb340b9ff9ad4a0245c31c92d34f3527da72a8! Thank you for your contribution 🎉