Struct RCalc

Source
pub struct RCalc { /* private fields */ }
Expand description

Main calculator struct

Implementations§

Source§

impl RCalc

Source

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]);
Source

pub fn e3(count: usize) -> Self

Creates a new RCalc with count resistors drawn from the E3 series.

Source

pub fn e6(count: usize) -> Self

Creates a new RCalc with count resistors drawn from the E6 series.

Source

pub fn e12(count: usize) -> Self

Creates a new RCalc with count resistors drawn from the E12 series.

Source

pub fn e24(count: usize) -> Self

Creates a new RCalc with count resistors drawn from the E24 series.

Source

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.

Source

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§

Source§

impl Debug for RCalc

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.