Skip to content

Format and lint code #210

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

Merged
merged 3 commits into from
Apr 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- stable
- beta
- nightly
- 1.65.0 # MSRV
- 1.70.0 # MSRV

steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ An implementation of a LRU cache. The cache supports `put`, `get`, `get_mut` and
all of which are O(1). This crate was heavily influenced by the [LRU Cache implementation in an
earlier version of Rust's std::collections crate].

The MSRV for this crate is 1.65.0.
The MSRV for this crate is 1.70.0.

## Example

Expand Down
9 changes: 3 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,10 +269,7 @@ impl<K: Hash + Eq, V, S: BuildHasher> LruCache<K, V, S> {
/// let mut cache: LruCache<isize, &str> = LruCache::unbounded_with_hasher(s);
/// ```
pub fn unbounded_with_hasher(hash_builder: S) -> LruCache<K, V, S> {
LruCache::construct(
NonZeroUsize::MAX,
HashMap::with_hasher(hash_builder),
)
LruCache::construct(NonZeroUsize::MAX, HashMap::with_hasher(hash_builder))
}

/// Creates a new LRU Cache with the given capacity.
Expand Down Expand Up @@ -1502,7 +1499,7 @@ impl<K: Hash + Eq, V, S: BuildHasher> LruCache<K, V, S> {
fn remove_first(&mut self) -> Option<Box<LruEntry<K, V>>> {
let next;
unsafe { next = (*self.head).next }
if next != self.tail {
if !core::ptr::eq(next, self.tail) {
let old_key = KeyRef {
k: unsafe { &(*(*(*self.head).next).key.as_ptr()) },
};
Expand All @@ -1518,7 +1515,7 @@ impl<K: Hash + Eq, V, S: BuildHasher> LruCache<K, V, S> {
fn remove_last(&mut self) -> Option<Box<LruEntry<K, V>>> {
let prev;
unsafe { prev = (*self.tail).prev }
if prev != self.head {
if !core::ptr::eq(prev, self.head) {
let old_key = KeyRef {
k: unsafe { &(*(*(*self.tail).prev).key.as_ptr()) },
};
Expand Down
Loading