apocalypse/demon/
location.rs1use std::marker::PhantomData;
2use std::hash::{Hash, Hasher};
3
4pub struct Location<E: ?Sized> {
8 pub(crate) address: usize,
10 pub(crate) phantom: PhantomData<E>
12}
13
14impl<A> AsRef<Location<A>> for Location<A> {
15 fn as_ref(&self) -> &Location<A> {
16 &self
17 }
18}
19
20impl<E> Clone for Location<E> {
21 fn clone(&self) -> Location<E> {
22 Location {
23 address: self.address,
24 phantom: PhantomData
25 }
26 }
27}
28
29impl<E> Hash for Location<E> {
30 fn hash<H: Hasher>(&self, state: &mut H) {
31 self.address.hash(state);
32 }
33}
34
35impl<E> PartialEq for Location<E> {
36 fn eq(&self, other: &Self) -> bool {
37 self.address == other.address
38 }
39}
40
41impl<E> Eq for Location<E>{}
42
43impl<E> std::fmt::Display for Location<E> {
44 fn fmt(&self, formatter: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
45 write!(formatter, "d-{}", self.address)
46 }
47}