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

LRU Cache implementation #10

Merged
merged 2 commits into from
Feb 4, 2018
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: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#![feature(try_from)]
#![feature(cfg_target_feature)]
#![feature(nll)]
#![feature(match_default_bindings)]
#![feature(conservative_impl_trait)]

extern crate arena;
extern crate crossbeam;
Expand Down
9 changes: 8 additions & 1 deletion src/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@

use std::{ptr, slice};
use std::cmp::Ordering;
use std::hash::{Hash, Hasher};
use std::ops::Index;

use util::bit;

/// Just like Rust's slice, except there's no borrowing. Instead, the user needs to
/// guarantee that the instances of this struct should not live longer than the memory
/// that `data` points to.
#[derive(Clone, Debug)]
#[derive(Clone, Debug)] // TODO: double check Hash
pub struct Slice {
data: *const u8,
size: usize
Expand Down Expand Up @@ -169,3 +170,9 @@ impl PartialEq for Slice {
}

impl Eq for Slice { }

impl Hash for Slice {
fn hash<H: Hasher>(&self, state: &mut H) {
state.write(self.data());
}
}
Loading