Debian Codegraph @

debian/rust-vendor/bitvec/doc/ptr/eq.md

raw
1 # Bit-Pointer Equality
2
3 This compares two bit-pointers for equality by their address value, not by the
4 value of their referent bit. This does not dereference either.
5
6 ## Original
7
8 [`ptr::eq`](core::ptr::eq)
9
10 ## API Differences
11
12 The two bit-pointers can differ in their storage type parameters. `bitvec`
13 defines pointer equality only between pointers with the same underlying
14 [`BitStore::Mem`][0] element type. Numerically-equal bit-pointers with different
15 integer types *will not* compare equal, though this function will compile and
16 accept them.
17
18 This cannot compare encoded span poiters. `*const BitSlice` can be used in the
19 standard-library `ptr::eq`, and does not need an override.
20
21 ## Examples
22
23 ```rust
24 use bitvec::prelude::*;
25 use bitvec::ptr as bv_ptr;
26 use core::cell::Cell;
27
28 let data = 0u16;
29 let bare_ptr = BitPtr::<_, _, Lsb0>::from_ref(&data);
30 let cell_ptr = bare_ptr.cast::<Cell<u16>>();
31
32 assert!(bv_ptr::eq(bare_ptr, cell_ptr));
33
34 let byte_ptr = bare_ptr.cast::<u8>();
35 assert!(!bv_ptr::eq(bare_ptr, byte_ptr));
36 ```
37
38 [0]: crate::store::BitStore::Mem