Commit aa6180f
committed
frontier: tighter integration with rust traits
The `frontier` module implements a common Rust pattern where there is
one type representing a mutable version of something and a separate type
representing its immutable counterpart. Examples in std are `String` and
`str`, `PathBuf` and `Path`, `OsString` and `OsStr`, and other.
In all the examples above the mutable version holds onto a heap
allocated buffer and the immutable version is just a
`#[repr(transparent)]` wrapper over an raw unsized slice of the data
type.
This patch changes `AntichainRef<T>` to simply be a transparent wrapper
over `[T]`. This change enables `Deref` implementations targeting the
immutable antichain from both `MutableAntichain<T>` and `Antichain<T>`.
This has a bunch of ergonomic improvements for users (due to auto-deref)
and also allows having a single implementation of all methods that only
need immutable access to the antichain.
Specifically, the following methods have been deduplicated and are now
implemented in only once place:
* `AntichainRef::less_than`
* `AntichainRef::less_equal`
* `AntichainRef::dominates`
* `AntichainRef::elements`
* `<AntichainRef as PartialEq>::eq`
* `<AntichainRef as PartialOrd>::partial_cmp`
* `<AntichainRef as Hash>::hash`
Finally, this change also enables replacing the inherent
`Antichain::borrow` and `Antichain::to_owned` methods by implementing
the `std::borrow::Borrow` and `std::borrow::ToOwned` traits
respectively.
Signed-off-by: Petros Angelatos <[email protected]>1 parent 7ad8962 commit aa6180f
File tree
5 files changed
+78
-209
lines changed- timely/src
- dataflow/operators
- generic
- progress
5 files changed
+78
-209
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
44 | | - | |
| 43 | + | |
| 44 | + | |
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
127 | | - | |
| 127 | + | |
128 | 128 | | |
129 | | - | |
| 129 | + | |
130 | 130 | | |
131 | 131 | | |
132 | 132 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
166 | 166 | | |
167 | 167 | | |
168 | 168 | | |
169 | | - | |
170 | | - | |
| 169 | + | |
| 170 | + | |
171 | 171 | | |
172 | 172 | | |
173 | 173 | | |
| |||
0 commit comments