Skip to content

Commit f1caa07

Browse files
committed
add another convenience helper (union_value) for infallible keys
1 parent f744b7e commit f1caa07

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description = "Union-find, congruence closure, and other unification code. Based
44
license = "MIT/Apache-2.0"
55
homepage = "https://github.com/nikomatsakis/ena"
66
repository = "https://github.com/nikomatsakis/ena"
7-
version = "0.7.1"
7+
version = "0.7.2"
88
authors = ["Niko Matsakis <niko@alum.mit.edu>"]
99

1010
[features]

src/unify/mod.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,13 +453,23 @@ impl<'tcx, K, V> UnificationTable<K>
453453
V: UnifyValue,
454454
{
455455
/// Unions two keys without the possibility of failure; only
456-
/// applicable to InfallibleUnifyValue.
456+
/// applicable when unify values use `NoError` as their error
457+
/// type.
457458
pub fn union(&mut self, a_id: K, b_id: K)
458459
where V: UnifyValue<Error = NoError>
459460
{
460461
self.unify_var_var(a_id, b_id).unwrap();
461462
}
462463

464+
/// Unions a key and a value without the possibility of failure;
465+
/// only applicable when unify values use `NoError` as their error
466+
/// type.
467+
pub fn union_value(&mut self, id: K, value: V)
468+
where V: UnifyValue<Error = NoError>
469+
{
470+
self.unify_var_value(id, value).unwrap();
471+
}
472+
463473
/// Given two keys, indicates whether they have been unioned together.
464474
pub fn unioned(&mut self, a_id: K, b_id: K) -> bool {
465475
self.find(a_id) == self.find(b_id)

0 commit comments

Comments
 (0)