#hash #pointer #reference #rc #arc

no-std by_address

Wrapper for comparing and hashing pointers by address

6 stable releases

2.1.0 Oct 28, 2022
2.0.0 Apr 22, 2019
1.1.0 Oct 28, 2022
1.0.4 Jan 19, 2018
1.0.2 Oct 23, 2017

#329 in Rust patterns

Download history 15793/week @ 2023-10-27 15489/week @ 2023-11-03 19604/week @ 2023-11-10 17523/week @ 2023-11-17 19444/week @ 2023-11-24 19441/week @ 2023-12-01 19092/week @ 2023-12-08 16595/week @ 2023-12-15 9038/week @ 2023-12-22 11755/week @ 2023-12-29 17993/week @ 2024-01-05 19963/week @ 2024-01-12 21142/week @ 2024-01-19 20654/week @ 2024-01-26 20641/week @ 2024-02-02 15341/week @ 2024-02-09

81,148 downloads per month
Used in 100 crates (28 directly)

MIT/Apache

13KB
261 lines

by_address

Rust wrapper type that implements hashing and comparison based on address rather than value.

Overview

ByAddress can be used to wrap any pointer type (i.e. any type that implements the Deref trait). This includes references, raw pointers, smart pointers like Rc<T> and Box<T>, and specialized pointer-like types such as Vec<T> and String.

The wrapped pointer implements the following traits based on the address of its contents, rather than their value:

  • Hash
  • Eq, PartialEq
  • Ord, PartialOrd

no_std

This crate does not depend on libstd, so it can be used in no_std projects.

Release notes

Version 1.1.0

  • New ByThinAddress type.
  • Implement the Display trait.
  • Custom implementation of Debug that includess the pointer address.

Version 1.0.4

  • Improve hashing of fat pointers

Version 1.0.3

  • Implement From<T> for ByAddress<T>
  • More documentation fixes

Version 1.0.2

  • More documentation fixes

Version 1.0.1

  • Improved documentation

Version 1.0.0

  • Initial release

License

Licensed under the Apache License, Version 2.0 or the MIT license, at your option. See the license files in this directory for details.

No runtime deps