I am running up against the word fuse
in the Rust ecosystem:
slog::Fuse
to promote errors to panics.
FutureExt::Fuse
"Fuse a future such that poll will never again be called once it has completed."
I'm aware of Linux's FUSE, a userspace filesystem. A fuse is also an electrical component that goes into open circuit state when too much current goes through the fuse. In hardware "fusing" describes baking configuration into the silicon by (historically) blowing circuits in the silicon through over-current in specific wires of the silicon.
What does "fuse" generally mean in Rust and what is its etymology?
The earliest use I could find of "fuse" in the Rust ecosystem is Iterator::fuse
, which was added to the standard library during the pre-1.0 days. The initial documentation for Iterator::fuse
said:
/// Creates an iterator that yields `None` forever after the underlying
/// iterator yields `None`. Random-access iterator behavior is not
/// affected, only single and double-ended iterator behavior.
There was also a function on the returned iterator that has since been removed:
impl<T> Fuse<T> {
/// Resets the fuse such that the next call to .next() or .next_back() will
/// call the underlying iterator again even if it prevously returned None.
#[inline]
fn reset_fuse(&mut self) {
self.done = false
}
}
This indicates that Fuse
is an analogy to a resettable electric fuse. The name is entirely unrelated to the FUSE filesystem.
FutureExt::Fuse
is basically the Future
equivalent to Iterator::Fuse
. Support for Future
s in Rust came far after support for Iterator
s.
The common thread here is that a fuse
function takes "a thing that produces things, and can stop", and makes it so it doesn't produce things after it stops.
slog::Fuse
is not a typical use of the word "fuse": that use might be referencing the fuse of a bomb, which is easily ignited (it makes errors easily ignite/panic the program). You can kinda fit it onto the earlier definition I made if you think of it as "a thing produces a stream of successes/failures, and fuse
takes a failure and makes it so it doesn't produce anything more after a failure". The commit that added it doesn't provide any hints as to the meaning.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With