pub struct Wire(/* private fields */);Expand description
The position of a source cell or of an operation’s result.
Implementations§
Source§impl Wire
impl Wire
Sourcepub fn from_index(index: usize) -> Wire
pub fn from_index(index: usize) -> Wire
A wire at a position counted by hand, like handwired’s asWire.
Sourcepub fn index(self) -> usize
pub fn index(self) -> usize
Examples found in repository?
examples/toggle.rs (line 150)
148 pub fn step(&mut self, width: f32, height: f32, events: &[PointerEvent]) -> Result<Output, String> {
149 let mut values = self.source.clone();
150 values[self.viewport.0.index()] = width;
151 values[self.viewport.1.index()] = height;
152 for event in events {
153 let pointer = match event.kind {
154 PointerKind::Down => &self.down,
155 PointerKind::Up => &self.up,
156 PointerKind::Cancel => {
157 values[self.cancel.index()] = 1.0;
158 continue;
159 }
160 };
161 values[pointer.active.index()] = 1.0;
162 values[pointer.x.index()] = event.x;
163 values[pointer.y.index()] = event.y;
164 }
165 self.table.validate(&values)?;
166 let result = self.circuit.evaluate_tensor(&values, &self.program).map_err(|error| error.to_string())?;
167 self.source = self.table.advance(&values, &result);
168 let [track_left, track_top, on, armed] = self.outputs.map(|wire| result[wire.index()]);
169 Ok(Output { track_left, track_top, on, armed })
170 }Trait Implementations§
impl Copy for Wire
impl Eq for Wire
Source§impl Ord for Wire
impl Ord for Wire
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialOrd for Wire
impl PartialOrd for Wire
impl StructuralPartialEq for Wire
Auto Trait Implementations§
impl Freeze for Wire
impl RefUnwindSafe for Wire
impl Send for Wire
impl Sync for Wire
impl Unpin for Wire
impl UnsafeUnpin for Wire
impl UnwindSafe for Wire
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
Mutably borrows from an owned value. Read more