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

Removed unused Borrow trait requirements #53

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

peter-scholtens
Copy link
Contributor

As mentioned in #50 question 1, the unused Borrow trait requirements are removed. Some other code is aligned using rustfmt --edition 2021

* Cache takes ownership of input data

The cache example now owns the data, and not static references, as mentioned in al8n#48 Also variable names are modified to explain their usage.

* Update sync_example.rs

The cache example now owns the data, and not static references, as mentioned in al8n#48 Also variable names are modified to explain their usage.
While reviewing the code I was a confused by the name num_entries which suggest an integer while actually a fractional number is used. Changing this to usize makes the function call 7 machine code instructions shorter and the function body longer 5 instructions longer (from 65 to 70, as checked by the compiler explorer https://godbolt.org/ ). So with improved code readability also 2 instructions less are needed.
@codecov
Copy link

codecov bot commented May 4, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 85.40%. Comparing base (cccb12b) to head (d350418).
Report is 2 commits behind head on main.

❗ Current head d350418 differs from pull request most recent head 34e6023. Consider uploading reports for the commit 34e6023 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #53      +/-   ##
==========================================
- Coverage   85.74%   85.40%   -0.34%     
==========================================
  Files          17       17              
  Lines        1831     1830       -1     
==========================================
- Hits         1570     1563       -7     
- Misses        261      267       +6     

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

@al8n
Copy link
Owner

al8n commented May 7, 2023

Thanks! But I just found that if we remove the borrow limit, we are unable to limit the Q related to the type of the key.

Basically, I think we can add a new kind of Cache, which only requires a generic for Value, and in that kind cache, we remove the borrow limitation there and accept any kind of key.

@peter-scholtens
Copy link
Contributor Author

Okay, I leave the choice to you.
You mean adding a new cache like the example I proposed here? You can abbreviate it to BKeyCache or BKCache and let it coexist with the current implementation first. Once the new cache is mature enough you can set the other one as deprecated and even later on remove or alias it to the new implementation.

@al8n al8n force-pushed the main branch 2 times, most recently from fde836e to cccb12b Compare October 17, 2023 15: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.

2 participants