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

refactor quality and use TryFrom instead of custom trait #1797

Merged
merged 2 commits into from
Nov 24, 2020

Conversation

robjtede
Copy link
Member

@robjtede robjtede commented Nov 24, 2020

PR Type

Refactor

PR Checklist

  • Tests for the changes have been added / updated.
  • Documentation comments have been added / updated.
  • A changelog entry has been made for the appropriate packages.
  • Format code with the latest stable rustfmt

Overview

Refactor Quality struct and associated methods. Now uses TryFrom for u16 and f32 conversions instead of the old custom sealed trait IntoQuality. Since it was sealed this change is fully compatible (the q function still panics on out-of-range numbers) but now Quality can be created by lib consumer using these standard traits as well.

@robjtede robjtede added A-http project: actix-http B-semver-patch labels Nov 24, 2020
@robjtede robjtede requested a review from a team November 24, 2020 02:52
@codecov
Copy link

codecov bot commented Nov 24, 2020

Codecov Report

Merging #1797 (304a962) into master (70f4747) will decrease coverage by 0.06%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1797      +/-   ##
==========================================
- Coverage   53.82%   53.75%   -0.07%     
==========================================
  Files         128      131       +3     
  Lines       12262    12277      +15     
==========================================
  Hits         6600     6600              
- Misses       5662     5677      +15     
Impacted Files Coverage Δ
actix-http/src/header/mod.rs 26.85% <ø> (ø)
actix-http/src/header/shared/charset.rs 0.00% <ø> (ø)
actix-http/src/header/shared/quality_item.rs 0.00% <0.00%> (ø)
actix-http/src/header/common/mod.rs 7.69% <0.00%> (-2.31%) ⬇️
actix-http/src/header/common/last_modified.rs
actix-http/src/header/common/content_language.rs 0.00% <0.00%> (ø)
actix-http/src/header/common/allow.rs 0.00% <0.00%> (ø)
actix-http/src/header/common/if_match.rs 0.00% <0.00%> (ø)
actix-http/src/header/common/if_modified_since.rs 0.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 70f4747...304a962. Read the comment docs.

@jplatte
Copy link
Contributor

jplatte commented Nov 24, 2020

I guess you could also provide an infallible From<u8> conversion, but not sure whether that would be useful.

@robjtede
Copy link
Member Author

I guess you could also provide an infallible From conversion, but not sure whether that would be useful.

Hmm, yeah... an infallible u8 constructor wouldn't be able to use what is arguably the most useful value of 1000.

@robjtede robjtede merged commit 5af4677 into master Nov 24, 2020
@robjtede robjtede deleted the refactor/quality branch November 24, 2020 11:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-http project: actix-http B-semver-patch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants