[−][src]Struct logicsim::circuits::WordInput
Data Structure that allows you to easily manage a group of LeverHandles.
Example
let input = WordInput::new(&mut g, 3, "input"); let output = g.output(&input.bits(), "result"); let ig = &mut g.init(); assert_eq!(output.u8(ig), 0); input.set_to(ig, 2); assert_eq!(output.u8(ig), 2); input.set_bit(ig, 0); assert_eq!(output.u8(ig), 3); input.flip_bit(ig, 1); assert_eq!(output.u8(ig), 1);
Implementations
impl WordInput
[src]
pub fn new<S: Into<String>>(
g: &mut GateGraphBuilder,
width: usize,
name: S
) -> Self
[src]
g: &mut GateGraphBuilder,
width: usize,
name: S
) -> Self
Returns a new WordInput of width width
with name name
.
pub fn update_bit(
&self,
g: &mut InitializedGateGraph,
bit: usize,
value: bool
) -> Option<()>
[src]
&self,
g: &mut InitializedGateGraph,
bit: usize,
value: bool
) -> Option<()>
Sets the lever at index bit
to value
.
pub fn flip_bit(&self, g: &mut InitializedGateGraph, bit: usize) -> Option<()>
[src]
Flips the lever at index bit
.
pub fn set_bit(&self, g: &mut InitializedGateGraph, bit: usize) -> Option<()>
[src]
Sets the lever at index bit
to true.
pub fn reset_bit(&self, g: &mut InitializedGateGraph, bit: usize) -> Option<()>
[src]
Sets the lever at index bit
to false.
pub fn set_to<T: Copy + Sized + 'static>(
&self,
g: &mut InitializedGateGraph,
value: T
)
[src]
&self,
g: &mut InitializedGateGraph,
value: T
)
Sets the levers to the native endian bits of value
.
If size_of_val(value) > self.len(), it will ignore the excess bits.
If size_of_val(value) < self.len(), it will 0 extend the value.
pub fn set(&self, g: &mut InitializedGateGraph)
[src]
Sets all the levers to true.
pub fn reset(&self, g: &mut InitializedGateGraph)
[src]
Sets all the levers to false.
pub fn bits(&self) -> SmallVec<[GateIndex; 8]>
[src]
pub fn len(&self) -> usize
[src]
Returns the width of the WordInput.
pub fn is_empty(&self) -> bool
[src]
Returns true the width of the WordInput == 0.
Auto Trait Implementations
impl RefUnwindSafe for WordInput
impl Send for WordInput
impl Sync for WordInput
impl Unpin for WordInput
impl UnwindSafe for WordInput
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,