pub struct Assignment(/* private fields */);Expand description
An assignment of a set of variables.
Inside the set of variables involved in the assignment, some may be unassigned.
This is the reason why accessors to assigned value return an Option<bool>.
Implementations§
Source§impl Assignment
impl Assignment
Sourcepub fn value_of<T>(&self, v: T) -> Option<bool>
pub fn value_of<T>(&self, v: T) -> Option<bool>
Returns the value potentially assigned to the variable.
The result in an Option. In case the variable is not assigned, Option::None is returned. Else, Option::Some is returned and contains the assigned value.
In order to iterate over an assignment, prefer the iter function.
§Panic
If the provided variable does not belong to the underlying problem, this function panics.
§Example
let assignment = get_assignment(); // user defined function
let n_vars = get_n_vars(); // user defined function
for i in 1 ..= n_vars {
match assignment.value_of(i) {
Some(v) => println!("var {} is set to {}", i, v),
None => println!("var {} is left unassigned", i),
}
}Sourcepub fn iter(&self) -> impl Iterator<Item = (usize, Option<bool>)> + '_
pub fn iter(&self) -> impl Iterator<Item = (usize, Option<bool>)> + '_
Iterates over an assignment.
Yielded values are Option. In case the variable is not assigned, Option::None is returned. Else, Option::Some is returned and contains the assigned value.
§Example
let assignment = get_assignment(); // user defined function
assignment.iter().for_each(|opt_lit| {
match opt_lit {
(i, Some(v)) => println!("var {} is set to {}", i, v),
(i, None) => println!("var {} is left unassigned", i),
}
});Trait Implementations§
Source§impl Debug for Assignment
impl Debug for Assignment
Source§impl PartialEq for Assignment
impl PartialEq for Assignment
impl Eq for Assignment
impl StructuralPartialEq for Assignment
Auto Trait Implementations§
impl Freeze for Assignment
impl RefUnwindSafe for Assignment
impl Send for Assignment
impl Sync for Assignment
impl Unpin for Assignment
impl UnwindSafe for Assignment
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