Make Your Rust Code Unit Testable With Dependency Inversion

Use Traits to invert your Rust dependencies and keep your code loosely coupled and testable

Kraig McFadden
Rust in Production
Published in
11 min readSep 28, 2023

--

Photo by James Peacock on Unsplash

It was an epiphany moment when I figured out Java classes could be mocked by extending them and overriding their public methods.

--

--

Kraig McFadden
Rust in Production

Staff backend software engineer. Pursuing an MDIV at Reformed Theological Seminary. Princeton 2018 - Electrical Engineering. Opinions are my own.