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

Implements Iterator for Leds #41

Merged
merged 10 commits into from
Jun 25, 2021
Merged

Implements Iterator for Leds #41

merged 10 commits into from
Jun 25, 2021

Conversation

rubberduck203
Copy link
Owner

@rubberduck203 rubberduck203 commented Jun 24, 2021

  • Deprecates into_array
  • Appears to save quite a bit of code size over the old method of calling into_array().iter_mut() by implementing Iterator for 'a &mut Leds directly.

image


James Munn helpfully pointed out that this saved an actual ~500 bytes, which is far more in line with what I expected to save.
Still a huge win.


A more controlled experiment suggests this saves 796 bytes over calling leds.into_array().iter_mut().

image

27c27
<     let leds = Leds::new(
---
>     let mut leds = Leds::new(
40,41d39
<     let mut arr = leds.into_array();
< 
45c43
<         for led in arr.iter_mut() {
---
>         for led in &mut leds {

examples/leds_iterator_test.rs Outdated Show resolved Hide resolved
src/leds.rs Show resolved Hide resolved
src/leds.rs Show resolved Hide resolved
@rubberduck203 rubberduck203 merged commit 331b726 into master Jun 25, 2021
@rubberduck203 rubberduck203 deleted the leds-iter branch June 25, 2021 00:07
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.

None yet

1 participant