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

Handle empty input in median #612

Merged
merged 1 commit into from
Nov 13, 2023

Conversation

vil02
Copy link
Member

@vil02 vil02 commented Nov 13, 2023

Pull Request Template

Description

The median function crashes for empty inputs. Since there is no nan for types integer types, I decided to return Option<T> from median.

Type of change

  • Breaking change (fix or feature that would cause existing functionality to not work as expected) (well, I change the return type, but everything works).

Checklist:

  • I ran bellow commands using the latest version of rust nightly.
  • I ran cargo clippy --all -- -D warnings just before my last commit and fixed any issue that was found.
  • I ran cargo fmt just before my last commit.
  • I ran cargo test just before my last commit and all tests passed.
  • I checked COUNTRIBUTING.md and my code follows its guidelines.

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (ed80173) 94.40% compared to head (a9f6ce3) 94.40%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #612   +/-   ##
=======================================
  Coverage   94.40%   94.40%           
=======================================
  Files         269      269           
  Lines       21850    21855    +5     
=======================================
+ Hits        20628    20633    +5     
  Misses       1222     1222           
Files Coverage Δ
src/math/average.rs 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@vil02 vil02 marked this pull request as ready for review November 13, 2023 17:11
@vil02 vil02 requested review from siriak and imp2002 as code owners November 13, 2023 17:11
Copy link
Member

@siriak siriak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

@siriak siriak merged commit d1369f2 into TheAlgorithms:master Nov 13, 2023
5 checks passed
@vil02 vil02 deleted the handle_empty_input_in_median branch November 13, 2023 18:17
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.

3 participants