Trait Translatable

Source
pub trait Translatable {
    // Required method
    fn translate<I1, I2>(&self, win: I1, wout: I2) -> Option<Self>
       where Self: Sized,
             I1: Iterator<Item = usize>,
             I2: Iterator<Item = usize>;

    // Provided methods
    fn translate_from_hashmap<'a>(
        &'a self,
        translation_table: HashMap<usize, usize>,
    ) -> Option<Self>
       where Self: Sized + HasIO,
             InputIterator<'a, Self>: Iterator<Item = usize>,
             OutputIterator<'a, Self>: Iterator<Item = usize> { ... }
    fn translate_from_fn<'a>(
        &'a self,
        input_mapper: fn(usize) -> usize,
        output_mapper: fn(usize) -> usize,
    ) -> Option<Self>
       where Self: Sized + HasIO,
             InputIterator<'a, Self>: Iterator<Item = usize>,
             OutputIterator<'a, Self>: Iterator<Item = usize> { ... }
}
Expand description

Defines a number of helper methods for replacing the I/O wires on a gate with new ones

Required Methods§

Source

fn translate<I1, I2>(&self, win: I1, wout: I2) -> Option<Self>
where Self: Sized, I1: Iterator<Item = usize>, I2: Iterator<Item = usize>,

takes an iterator of input wires and an iterator of output wires, and creates a new gate of the same type using the inputs and outputs. The current input and output wires have no bearing on the new wires, just the gate type.

Provided Methods§

Source

fn translate_from_hashmap<'a>( &'a self, translation_table: HashMap<usize, usize>, ) -> Option<Self>
where Self: Sized + HasIO, InputIterator<'a, Self>: Iterator<Item = usize>, OutputIterator<'a, Self>: Iterator<Item = usize>,

Takes a hashmap, and looks for existing wires in the keys. Replaces any existing wire keys with the value from the hashmap.

Source

fn translate_from_fn<'a>( &'a self, input_mapper: fn(usize) -> usize, output_mapper: fn(usize) -> usize, ) -> Option<Self>
where Self: Sized + HasIO, InputIterator<'a, Self>: Iterator<Item = usize>, OutputIterator<'a, Self>: Iterator<Item = usize>,

Calls a function on the I/O wires and replaces them with the output of the function.

Implementors§