fn link(ptr: &Result<PrincipalId, u32>, iplan: &Plan, oplan: &Plan) -> Result<PrincipalId, u32> {
    if *ptr == Err(0) {
        return Ok(LIFELINE_CANISTER_ID.get());
    }
    match (iplan, oplan) {
        (Plan::CanisterAccount(i, _), Plan::CanisterAccount(o, _)) if i == ptr => *o,
        (Plan::IdentityAccount(i, _), Plan::IdentityAccount(o, _)) if principal(i) == *ptr => {
            principal(o)
        }
        (Plan::CanisterAccount(_, itail), Plan::CanisterAccount(_, otail))
        | (Plan::IdentityAccount(_, itail), Plan::IdentityAccount(_, otail))
        | (Plan::Transfer(_, itail), Plan::Transfer(_, otail)) => link(ptr, itail, otail),
        _ => panic!("cannot happen! {:?}", (ptr, iplan, oplan)),
    }
}
/// `link` resolves a numerical canister identifier to a principal
/// given the raw plan vs. the populated plan.
`link` resolves a numerical canister identifier to a principal
given the raw plan vs. the populated plan.
` link ` resolves a numerical canister identifier to a principal given the raw plan vs . the populated plan .
fn link(ptr: &Result<PrincipalId, u32>, iplan: &Plan, oplan: &Plan) -> Result<PrincipalId, u32> {
    if *ptr == Err(0) {
        return Ok(LIFELINE_CANISTER_ID.get());
    }
    match (iplan, oplan) {
        (Plan::CanisterAccount(i, _), Plan::CanisterAccount(o, _)) if i == ptr => *o,
        (Plan::IdentityAccount(i, _), Plan::IdentityAccount(o, _)) if principal(i) == *ptr => {
            principal(o)
        }
        (Plan::CanisterAccount(_, itail), Plan::CanisterAccount(_, otail))
        | (Plan::IdentityAccount(_, itail), Plan::IdentityAccount(_, otail))
        | (Plan::Transfer(_, itail), Plan::Transfer(_, otail)) => link(ptr, itail, otail),
        _ => panic!("cannot happen! {:?}", (ptr, iplan, oplan)),
    }
}
fn link ( ptr : & Result < PrincipalId , u32 > , iplan : & Plan , oplan : & Plan ) -> Result < PrincipalId , u32 > { if * ptr == Err ( 0 ) { return Ok ( LIFELINE_CANISTER_ID . get ( ) ) ; } match ( iplan , oplan ) { ( Plan :: CanisterAccount ( i , _ ) , Plan :: CanisterAccount ( o , _ ) ) if i == ptr => * o , ( Plan :: IdentityAccount ( i , _ ) , Plan :: IdentityAccount ( o , _ ) ) if principal ( i ) == * ptr => { principal ( o ) } ( Plan :: CanisterAccount ( _ , itail ) , Plan :: CanisterAccount ( _ , otail ) ) | ( Plan :: IdentityAccount ( _ , itail ) , Plan :: IdentityAccount ( _ , otail ) ) | ( Plan :: Transfer ( _ , itail ) , Plan :: Transfer ( _ , otail ) ) => link ( ptr , itail , otail ) , _ => panic ! ( " " ( ptr iplan oplan ) ) , } }
`link` resolves a numerical canister identifier to a principal
given the raw plan vs. the populated plan.
` link ` resolves a numerical canister identifier to a principal given the raw plan vs . the populated plan .
ptr
&Result<PrincipalId, u32>
iplan
&Plan
oplan
&Plan
ptr
&Result<PrincipalId, u32>
iplan
&Plan
oplan
&Plan