1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
use ;
use crate::;
/// [`Expr`] wrapper that compares by reference instead of by value.
///
/// The standard [`Expr`] type uses *value* semantics for comparision: two [`Expr`]
/// instances are considered equal iff the Wolfram expression values they contain
/// are the same.
///
/// [`ExprRefCmp`] uses *reference* semantics for comparision: two [`ExprRefCmp`]
/// instances are considered equal iff they are pointers to the same
/// reference-counted expression allocation.
///
/// The [`Hash`] and [`PartialEq`] implementations for this type use the pointer
/// address of the reference counted expression data.
///
/// # Motivation
///
/// Two [`Expr`] instances will compare equal to each other if their values are
/// semantically the same. That means that even if the two [`Expr`] are
/// different allocations, they are still considered to be the same expression.
///
/// However, in some cases it is useful to distinguish [`Expr`] instances that
/// may contain semantically identical Wolfram expressions, but that are
/// different allocations.
///
/// For example, this type is used in `wl_parse::source_map` to give unique
/// source mappings, so that [`Expr`]s that are equal according to the
/// `PartialEq` impl for [`ExprKind`] (and whose hash values are therefore the
/// same) can be differentiated.
;
// TODO: Add tests that `ExprRefCmp` is working as expected