Radish alpha
r
rad:zwTxygwuz5LDGBq255RA2CbNGrz8
Radicle CI broker
Radicle
Git
ci_event: infallible constructors
Closed { reason: Solved } fintohaps opened 1 year ago

I was browsing through the code when I noticed that some of these constructors are infallible, e.g.

    pub fn patch_created(
        from_node: NodeId,
        repo: RepoId,
        patch: PatchId,
        tip: Oid,
    ) -> Result<Self, CiEventError> {
        Ok(Self::V1(CiEventV1::PatchCreated {
            from_node,
            repo,
            patch,
            new_tip: tip,
        }))
    }

    pub fn patch_updated(
        from_node: NodeId,
        repo: RepoId,
        patch: PatchId,
        new_tip: Oid,
    ) -> Result<Self, CiEventError> {
        Ok(Self::V1(CiEventV1::PatchUpdated {
            from_node,
            repo,
            patch,
            new_tip,
        }))
    }

I was wondering why you’d want to do this when the calling code can just construct it safely?

liw commented 1 year ago

I’ve not left a comment for myself, so this is retconning: I think it’s for consistency with the branch related constructors. Not sure that’s worth it.

liw commented 1 year ago

Refactored this code to drop the Results from constructors that don’t need them. Thanks.