Skip to main content

Weight

Trait Weight 

Source
pub trait Weight: Data {
    // Required methods
    fn set_zero(&mut self);
    fn is_zero(&self) -> bool;
    unsafe fn raw_add(&self, rhs: *const u8, result: *mut u8);
    unsafe fn raw_add_assign(&mut self, rhs: *const u8);
}
Expand description

A trait for types that can be used as weights in DBSP.

Such types must implement the plus operation and have a neutral element wrt addition (zero).

Required Methods§

Source

fn set_zero(&mut self)

Set the weight to zero.

Source

fn is_zero(&self) -> bool

Check if the weight is zero.

Source

unsafe fn raw_add(&self, rhs: *const u8, result: *mut u8)

Add the value of rhs to self, store the result in result.

§Safety

rhs and result must be valid pointers to values of type Self.

Source

unsafe fn raw_add_assign(&mut self, rhs: *const u8)

Add the value of rhs to self, store the result in self.

§Safety

rhs must be a valid pointer to a value of type Self

Blanket Implementations§

Source§

impl<V> Erase<dyn Weight> for V

Source§

fn erase(&self) -> &(dyn Weight + 'static)

Convert a reference to self into a reference to Trait.
Source§

fn erase_mut(&mut self) -> &mut (dyn Weight + 'static)

Convert a mutable reference to self into a mutable reference to Trait.
Source§

fn erase_box(self: Box<V>) -> Box<dyn Weight>

Convert Box<Self> into Box<Trait>.
Source§

fn erase_archived( archived: &<V as Archive>::Archived, ) -> &<dyn Weight as ArchiveTrait>::Archived

Convert a reference to an archived representation of Self into a reference to a trait object of type Trait::Archived.

Implementors§

Source§

impl<T: DBWeight> Weight for T