The inconsistency of `init` APIs
The init APIs of StableBTreeMap and StableVec returns inconsistent results:
StableBTreeMap::initreturnsStableBTreeMapStableVec::initreturnsResult<StableVec, InitError>ActuallyMinHeapalso returns aResult.
Looks like StableVec uses the safe_write method which returns a Result.
Should StableBTreeMap::init do the same thing and return a Result?
Is there a specific concern that you have or is it mostly about consistency/uniformity of the APIs?
The (not very good reason) this inconsistency exists is because these structures were written by different authors. The current thinking is to update them to all not return a Result, since the errors returned aren't really recoverable. Would be curious to hear your opinions on this issue.
Is there a specific concern that you have or is it mostly about consistency/uniformity of the APIs?
It's not a usage issue. For me, it's just a convention or a habit to make the high-level APIs consistent. :)
The (not very good reason) this inconsistency exists is because these structures were written by different authors. The current thinking is to update them to all not return a
Result, since the errors returned aren't really recoverable. Would be curious to hear your opinions on this issue.
If it's not recoverable or doesn't expect the users to handle the error, then not returning a Result is a better option IMO.