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.
I've been working with/reviewing the
AssignedCellAPI. And there's one thing that it's a bit annoying.When you need the value of the
Cellas V, you can callAssignedCell::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
MaybeUninitetc.. I suggested one that seemed to be Ok: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_elseor unwraps/expects in the code.