Crates.io | resistor |
lib.rs | resistor |
version | 0.1.0 |
source | src |
created_at | 2023-05-16 03:24:14.747313 |
updated_at | 2023-05-16 04:14:29.075739 |
description | calculating the resistance of a resistor based on the color bands |
homepage | |
repository | https://github.com/oovm/sub_projects |
max_upload_size | |
id | 865604 |
size | 16,307 |
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%)");
}