tamer: asg::graph::pre_add_edge: Use pre-narrowed source ObjectIndex
Since we're statically invoking a particular ObjectKind's method, we already know the source type. Let's pre-narrow it for their (my) convenience. DEV-13163main
parent
28b83ad6a3
commit
2ecc143e02
|
@ -430,12 +430,13 @@ pub trait AsgObjectMut: ObjectKind {
|
|||
/// and the commit cannot fail.
|
||||
/// If [`Err`] is provided to `commit`,
|
||||
/// then [`Asg::add_edge`] will fail with that error.
|
||||
fn pre_add_edge<
|
||||
OA: ObjectIndexRelTo<OB>,
|
||||
OB: ObjectKind + ObjectRelatable,
|
||||
>(
|
||||
///
|
||||
/// Unlike the type of [`Asg::add_edge`],
|
||||
/// the source [`ObjectIndex`] has been narrowed to the appropriate
|
||||
/// type for you.
|
||||
fn pre_add_edge<OB: ObjectKind + ObjectRelatable>(
|
||||
asg: &mut Asg,
|
||||
_from_oi: &OA,
|
||||
_from_oi: ObjectIndex<Self>,
|
||||
_to_oi: ObjectIndex<OB>,
|
||||
_ctx_span: Option<Span>,
|
||||
commit: impl FnOnce(&mut Asg),
|
||||
|
|
|
@ -938,7 +938,13 @@ where
|
|||
ctx_span: Option<Span>,
|
||||
commit: impl FnOnce(&mut Asg),
|
||||
) -> Result<(), AsgError> {
|
||||
O::pre_add_edge(asg, self, to_oi, ctx_span, commit)
|
||||
O::pre_add_edge(
|
||||
asg,
|
||||
self.widen().must_narrow_into::<O>(),
|
||||
to_oi,
|
||||
ctx_span,
|
||||
commit,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -962,7 +968,13 @@ impl<OB: ObjectRelatable> ObjectIndexRelTo<OB> for ObjectIndexTo<OB> {
|
|||
) -> Result<(), AsgError> {
|
||||
macro_rules! pre_add_edge {
|
||||
($ty:ident) => {
|
||||
$ty::pre_add_edge(asg, self, to_oi, ctx_span, commit)
|
||||
$ty::pre_add_edge(
|
||||
asg,
|
||||
self.widen().must_narrow_into::<$ty>(),
|
||||
to_oi,
|
||||
ctx_span,
|
||||
commit,
|
||||
)
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue