Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Object::len() and Object::is_empty() conflict with inherent len(), is_empty() #474

Closed
SergioBenitez opened this issue Apr 4, 2024 · 1 comment · Fixed by #476
Closed

Comments

@SergioBenitez
Copy link
Contributor

Calling self.len() inside of any method implementation (in particular, enumerate()) calls the trait method, which is unlikely to be what's desired. The only way to prevent this is to rename len() and is_empty() to something else.

I would suggest length() or enumerator_len() instead of len(). For is_empty(), maybe has_no_elements() or is_void() or is_vacant()?

@SergioBenitez SergioBenitez changed the title Object::len() and Object::is_empty() conflict with Vec::len(), Vec::is_empty() Object::len() and Object::is_empty() conflict with inherent len(), is_empty() Apr 4, 2024
@mitsuhiko
Copy link
Owner

mitsuhiko commented Apr 5, 2024

Yeah that's surprisingly annoying. In the rest of the engine is_empty is just the inverse (is_true). I just never really liked that name because it's not literally true, but true as far as the conditionals is concerned, but we could use this here too. Then at least it's consistent. I think enumerator_len is reasonable because you're supposed to match them anyways and that way this is more explicit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants