snapfitThe Snapfit Book (v0.1.1)

Welcome

Welcome to Snapfit

Hello, and welcome to The Snapfit Book.

snapfit is a compile-time dependency injection library for Rust. You declare your application's components in one struct, and snapfit writes the code that builds them, in the right order, each once, and refuses a missing dependency or a circle while the program compiles. Your services stay plain Rust: they never mention snapfit.

Why we start with the problem

A tool that solves a problem you haven't met yet is hard to judge. So this book doesn't start with snapfit. It starts with an ordinary online shop, written the way most Rust programs start, and we grow it together. Every time the shop grows, something starts to hurt, and we stop to look at why, give the problem a name, and try a fix. By the end of Part 1, what is left is exactly what snapfit was built for, and every chapter after that tells you which of those problems it answers.

If you already know dependency injection and just want to see the code, the Quick start shows a complete container on one page.

How the book is laid out