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