Skip to content

Better error handling for AssignedCell value queries #509

@CPerezz

Description

@CPerezz

I've been working with/reviewing the AssignedCell API. And there's one thing that it's a bit annoying.
When you need the value of the Cell as V, you can call AssignedCell::value, and that's great.

The problem is that it returns an Option<V> which then requires to do something like .ok_or_else(ERR_HANDLING)?;

After discussing with @therealyingtong different aproaches, like MaybeUninit etc.. I suggested one that seemed to be Ok:

Maybe value returning an Error where internally you handle the ok_or_else and so you can unify the error type returned.
Something like Error::CellNotAssigned.
So that when calling value you either get this or the value directly and match over the err as a user.

After that, the suggested err variant was Error::Synthesis.

I think that would help in cases where we need to do some extra stuff with the value and we don't want to end up with a bunch of ok_or_else or unwraps/expects in the code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions