liveBook · Manning

Determinism

As explained in Code Like a Pro in Rust

A deterministic computation produces the same result for the same inputs and relevant execution conditions.

A deterministic function returns the same result for a given set of inputs. Prefer deterministic functions when possible to make computations easier to test and less likely to be wrong. section 6.1

Apply this guidance when designing small units of computation:

  • Prefer stateless functions; when state is necessary, make functions idempotent. Handle possible failures with Result and possible absence with Option. section 6.1
  • Handle failure cases from I/O or nondeterministic operations appropriately. section 6.1

How Code Like a Pro in Rust covers it

How deep it goes
Defines determinism by repeatable results for given inputs and recommends it when possible, without discussing implementation internals.
What you can do after
Apply determinism by designing functions to return the same result for given inputs whenever possible.
How it connects
Connects determinism with statelessness, idempotence, unit testing, and explicit failure or absence handling through Result and Option.

Also explained in

Compare how 10 books explain determinism →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Code Like a Pro in Rust. The section links point to the parts of the book it draws on.