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

digest: Add AsRef<str> #229

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

cgwalters
Copy link
Contributor

@cgwalters cgwalters commented Sep 23, 2024

Conceptually Digest() is just a parsed string wrapper. Many cases want to get access to the full value without allocating, and the introduction of the type was a regression from that point of view in 0.7.

Luckily, we can change our internals in such a way that it's safe to add the impl. Do that by holding onto the full value, with a duplicate small boxed str for the algorithm only in the degenerate case that it's an unknown type.

If we had this it would have made containers/bootc#800 less likely.

What type of PR is this?

/kind feature

What this PR does / why we need it:

See commit message

Which issue(s) this PR fixes:

Special notes for your reviewer:

Does this PR introduce a user-facing change?

- Digest can now cheaply be viewed as a `&str` via `.as_ref()`

Conceptually `Digest()` is just a parsed string wrapper. Many
cases want to get access to the full value without allocating,
and the introduction of the type was a regression from that point of
view in 0.7.

Luckily, we can change our internals in such a way that it's
safe to add the impl. Do that by holding onto the full value,
with a duplicate small boxed str for the algorithm only in
the degenerate case that it's an unknown type.

If we had this it would have made containers/bootc#800
less likely.

Signed-off-by: Colin Walters <[email protected]>
@codecov-commenter
Copy link

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 70.77%. Comparing base (57570dd) to head (8aa75aa).
Report is 51 commits behind head on main.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@             Coverage Diff             @@
##             main     #229       +/-   ##
===========================================
+ Coverage   26.61%   70.77%   +44.15%     
===========================================
  Files          24       26        +2     
  Lines        2788     3168      +380     
  Branches     1516     1673      +157     
===========================================
+ Hits          742     2242     +1500     
+ Misses        948      926       -22     
+ Partials     1098        0     -1098     

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