Shortest pristine truth machine In this challenge, the goal is to create a pristine truth machine in as few bytes as possible. For reference, a truth machine does the following:

Takes input, which is always 0 or 1
If the input is 0, it is printed and the program terminates
If the input is 1, it is printed forever

A pristine program is one that does not error on its own, but will error if any single substring with a length \$1\le n&lt;p\$ is removed (where \$p\$ is the length of the program).
For example, if the main did not error in some language, it would be pristine if all of the following produced an error:
mai
man
min
ain
ma
mn
in
m
n

The goal of this challenge is to write the shortest program or function (in bytes, per language) which is a pristine truth machine.
Rust, 109 106 bytes

fn t(n:i8)-&gt;Result&lt;Box::&lt;Iterator::&lt;Item=i8&gt;&gt;,i8&gt;{if n==0{Err(0)}else{Ok(Box::new(std::iter::repeat(1)))}}

Try it online!
Returns a result whose ok variant is a dynamically typed iterator that always yields one wrapped in a smart pointer so the compiler can know its size. The error variant is simply zero. The code does emit a deprecation warning, so it may randomly stop working at some point in the future. Rust's type inference is too good for me to get a pristine closure, and as verbose as this solution is it is still shorting than fully listing the returned iterator's type and much shorter than using the main function and reading from stdin.
-3 bytes because there is a method to create an endlessly repeating iterator