Skip to main content

Depends

Struct Depends 

Source
pub struct Depends<T> { /* private fields */ }
Expand description

A quantity on every residue class of the generator. See the module documentation.

Implementations§

Source§

impl<T: Clone + PartialEq> Depends<T>

Source

pub fn constant(v: T, ty: &ResidueType) -> Depends<T>

Source

pub fn from_fn( m: u64, ty: &ResidueType, f: impl Fn(u64) -> T, ) -> Result<Depends<T>, ResidueError>

The quantity f(H mod m) on the classes the type admits; refused when m and the type’s modulus together pass MAX_MODULUS.

Source

pub fn from_branches( ty: ResidueType, m: u64, raw: Vec<Option<T>>, ) -> Option<Depends<T>>

Rebuild a quantity from its value on every class modulo m (None exactly for the classes ty rules out), held at its smallest modulus; None when the classes and the type disagree.

Source

pub fn raw_branches(&self) -> Vec<Option<T>>

The value on every class modulo Depends::modulus, None for a class the type rules out.

Source

pub fn modulus(&self) -> u64

Source

pub fn residue_type(&self) -> &ResidueType

Source

pub fn single(&self) -> Option<&T>

The value, when every admitted class has the same one.

Source

pub fn at(&self, h: u64) -> Option<&T>

The value at H = h; None when the type rules h out.

Source

pub fn branches(&self) -> impl Iterator<Item = (u64, &T)>

The admitted classes and their values, by residue.

Source

pub fn map<U: Clone + PartialEq>(&self, f: impl Fn(&T) -> U) -> Depends<U>

Source

pub fn zip_with<U: Clone + PartialEq, V: Clone + PartialEq>( &self, o: &Depends<U>, f: impl Fn(&T, &U) -> V, ) -> Result<Depends<V>, ResidueError>

Combine two quantities branch by branch; refused when their classes together pass MAX_MODULUS or their types admit no common class.

Source

pub fn render(&self, generator: &str, show: impl Fn(&T) -> String) -> String

v alone when it is single; otherwise the dependence on the generator, written generator: 0 when ⌈1/dt⌉ is even, 1 when it is odd, or one clause per class modulo the modulus.

Source§

impl Depends<Algebraic>

Source

pub fn apply(&self, rule: LimitRule) -> Result<Algebraic, String>

The value under rule, the generator written ⌈1/dt⌉ in an error.

Source

pub fn apply_with( &self, rule: LimitRule, generator: &str, ) -> Result<Algebraic, String>

The value under rule; an error naming the dependence (the generator written generator) when the rule demands a limit that does not exist.

Trait Implementations§

Source§

impl<T: Clone> Clone for Depends<T>

Source§

fn clone(&self) -> Depends<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug> Debug for Depends<T>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<T: ExactCodec + Clone + PartialEq> ExactCodec for Depends<T>

Source§

fn write(&self, out: &mut Vec<u8>)

The residue type, the modulus, then each class’s value (0 for a class the type rules out, 1 and the value otherwise).

Source§

fn read(buf: &[u8], pos: &mut usize) -> Option<Self>

Source§

fn to_bytes(&self) -> Vec<u8> ⓘ

Source§

fn from_bytes(buf: &[u8]) -> Option<Self>

The value buf canonically encodes, with nothing left over.
Source§

impl<T: Hash> Hash for Depends<T>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<T: PartialEq> PartialEq for Depends<T>

Source§

fn eq(&self, other: &Depends<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: Eq> Eq for Depends<T>

Source§

impl<T> StructuralPartialEq for Depends<T>

Auto Trait Implementations§

§

impl<T> Freeze for Depends<T>

§

impl<T> RefUnwindSafe for Depends<T>
where T: RefUnwindSafe,

§

impl<T> Send for Depends<T>
where T: Send,

§

impl<T> Sync for Depends<T>
where T: Sync,

§

impl<T> Unpin for Depends<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for Depends<T>

§

impl<T> UnwindSafe for Depends<T>
where T: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.