Skip to content

Rust type wrapper to cache hash of potentially large structures.

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

pali6/cachedhash

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CachedHash

Build Status Crates.io Docs.rs

For a type T, CachedHash<T> wraps T and implements Hash in a way that caches T's hash value. This is useful when T is expensive to hash (for example if it contains a large vector) and you need to hash it multiple times with few modifications (for example by moving it between multiple HashSets).

Stored hash is invalidated whenever the stored value is accessed mutably (via DerefMut, AsMut, BorrowMut or explicitly via a provided associated function). In order for the hash to be invalidated correctly the stored type cannot use interior mutability in a way that affects the hash. If this is the case, you can use CachedHash::invalidate_hash to invalidate the hash manually.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

About

Rust type wrapper to cache hash of potentially large structures.

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Packages

No packages published

Languages