Expand description
Resistor
resistor is a library for calculating the resistance of a resistor based on the color bands.
use resistor::{ResistorBuilder, ResistorColor};
#[test]
fn test_red4() {
let resistor = ResistorBuilder::FourBand {
first: ResistorColor::Red,
second: ResistorColor::Red,
multiplier: ResistorColor::Red,
tolerance: ResistorColor::Red,
}
.build()
.unwrap();
assert_eq!(resistor.resistance, 2200.0);
assert_eq!(resistor.to_string(), "Resistor(2200Ω ± 2%)");
}
Structs
- A resistor.
- An error that can occur when building a resistor.
Enums
- A builder for a resistor.
- The colors that can be used on a resistor.