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

Simplify todo example #3788

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

RandomInsano
Copy link

Description

Refactored the TODO example for readability and performance. Specifically:

  1. When creating the visible list of items, enumerate elements before filtering. This simplifies filtering in state.rs
  2. Renamed toggle_all to set_completed to be clearer on intention
  3. Renamed toggle to toggle_completed to be inline with set_completed
  4. Created new function for state (I'm not sure why I did this, can revert 🙂)
  5. Use Vec::retain to remove completed entries

As a newcomer I found it a bit hard to follow all of the iterator work being done in the state.rs file. It seemed that most were because the indexes were calculated after filtration in the view side, and hopefully this PR makes it easier for others.

Checklist

  • I have reviewed my own code
  • I have added tests

Copy link

github-actions bot commented Jan 4, 2025

Size Comparison

examples master (KB) pull request (KB) diff (KB) diff (%)

✅ None of the examples has changed their size significantly.

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 this pull request may close these issues.

1 participant