Reserve First

last updated: Aug 19, 2025

https://matklad.github.io/2025/08/16/reserve-first.html

In these two cases in particular, the only source of errors is fallible allocation. And there’s a pattern to fix it:

This seems to me a very similar principle to the one presented in Parse, don't validate - to perform a potentially dangerous operation, do work up front to change the environment and make errors impossible later on.

↑ up