simple-linked-list, doubly-linked-list: Add is_empty#1028
Merged
petertseng merged 2 commits intoexercism:masterfrom Nov 20, 2020
petertseng:isempty
Merged
simple-linked-list, doubly-linked-list: Add is_empty#1028petertseng merged 2 commits intoexercism:masterfrom petertseng:isempty
petertseng merged 2 commits intoexercism:masterfrom
petertseng:isempty
Conversation
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.
coriolinus
approved these changes
Nov 20, 2020
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 fieldthat 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 firstoh right, Clippy won't run on the exercises in question since PR checks only test changed exercises.