pub struct RCalc { /* private fields */ }Expand description
Main calculator struct
Implementations§
Source§impl RCalc
impl RCalc
Sourcepub fn new(rs: Vec<&'static RSeries>) -> Self
pub fn new(rs: Vec<&'static RSeries>) -> Self
Creates a new RCalc with the series used for the R values provided as a vec.
§Examples
To create a calculator that will vary over 4 resistors R1, R2, R3 and R4, where we want to draw R1 and R2 from the E24 series, R3 from the E6 series and R4 from the E12 series would be done as follows:
let rcal = RCalc::new(vec![&E24, &E24, &E6, &E12]);Sourcepub fn e3(count: usize) -> Self
pub fn e3(count: usize) -> Self
Creates a new RCalc with count resistors drawn from the E3 series.
Sourcepub fn e6(count: usize) -> Self
pub fn e6(count: usize) -> Self
Creates a new RCalc with count resistors drawn from the E6 series.
Sourcepub fn e12(count: usize) -> Self
pub fn e12(count: usize) -> Self
Creates a new RCalc with count resistors drawn from the E12 series.
Sourcepub fn e24(count: usize) -> Self
pub fn e24(count: usize) -> Self
Creates a new RCalc with count resistors drawn from the E24 series.
Sourcepub fn combinations(&self) -> u128
pub fn combinations(&self) -> u128
Returns the number of combinations of values that exist for the configured resistors and series. This will fairly directly map to the amount of time taken to calculate value combinations.
Sourcepub fn calc(&self, f: impl Fn(&RSet) -> Option<f64>) -> Option<RRes>
pub fn calc(&self, f: impl Fn(&RSet) -> Option<f64>) -> Option<RRes>
Given a testing function f thats maps from a set of input resistors to Option<f64> this
will calculate the results for the resistors and series configured and return the result as
an RRes. f should map combinations that are unsuitable to None and combinations that
are suitable to Some(err) where err is a f64 describing how far from perfect the
combination is. f is often supplied with the use of the ROpBuilder struct.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for RCalc
impl RefUnwindSafe for RCalc
impl Send for RCalc
impl Sync for RCalc
impl Unpin for RCalc
impl UnwindSafe for RCalc
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more