Skip to content

simple-linked-list, doubly-linked-list: Add is_empty#1028

Merged
petertseng merged 2 commits intoexercism:masterfrom
petertseng:isempty
Nov 20, 2020
Merged

simple-linked-list, doubly-linked-list: Add is_empty#1028
petertseng merged 2 commits intoexercism:masterfrom
petertseng:isempty

Conversation

@petertseng
Copy link
Copy Markdown
Member

@petertseng petertseng commented Nov 20, 2020

https://rust-lang.github.io/rust-clippy/master/index.html#len_without_is_empty

This alleges that for certain types, len() may be expensive, but
is_empty() is likely to always be cheap, and therefore it's good custom
to have both. I find this sufficiently persuasive. On the principle that
the track instill good habits in students, we will add and test such a
method.

I understand that for the example solutions, len() is actually cheap.
In addition, I understand that for a list it's always possible to be
able to cheaply determine the len() simply by keeping an extra field
that gets updated on every insert.

Nevertheless I think it's a good idea anyway.


doubly-linked-list: Test len in more places

I simply thought we could increase the thoroughness without being an
undue burden on readability or student completion.

This is limited to testing len in additional places in tests that were
already testing len or is_empty.
It hasn't added len in tests that didn't already have either of those
two.


For Clippy, see #1027 first oh right, Clippy won't run on the exercises in question since PR checks only test changed exercises.

https://rust-lang.github.io/rust-clippy/master/index.html#len_without_is_empty

This alleges that for certain types, len() may be expensive, but
is_empty() is likely to always be cheap, and therefore it's good custom
to have both. I find this sufficiently persuasive. On the principle that
the track instill good habits in students, we will add and test such a
method.

I understand that for the example solutions, len() is actually cheap.
In addition, I understand that for a list it's always possible to be
able to cheaply determine the `len()` simply by keeping an extra field
that gets updated on every insert.

Nevertheless I think it's a good idea anyway.

Helps address #1011
Helps address #1012
I simply thought we could increase the thoroughness without being an
undue burden on readability or student completion.

This is limited to testing len in additional places in tests that were
already testing len or is_empty.
It hasn't added len in tests that didn't already have either of those
two.
@petertseng petertseng merged commit 53acb5e into exercism:master Nov 20, 2020
@petertseng petertseng deleted the isempty branch November 20, 2020 08:42
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.

2 participants