Struct rustsat::types::Lit

source ·
pub struct Lit { /* private fields */ }
Expand description

Type representing literals, possibly negated boolean variables.

Implementations§

source§

impl Lit

source

pub fn new(idx: u32, negated: bool) -> Lit

Creates a new (negated or not) literal with a given index. Panics if idx > Var::MAX_IDX.

source

pub fn new_with_error(idx: u32, negated: bool) -> Result<Lit, TypeError>

Creates a new (negated or not) literal with a given index. Returns Err(TypeError::IdxTooHigh(idx, Var::MAX_IDX) if idx > Var::MAX_IDX.

source

pub fn new_unchecked(idx: u32, negated: bool) -> Lit

Creates a new (negated or not) literal with a given index. Does not perform any check on the index, therefore might produce an inconsistent variable. Only use this for performance reasons if you are sure that idx <= Var::MAX_IDX.

source

pub fn positive(idx: u32) -> Lit

Creates a new positive literal with a given index. Panics if idx > Var::MAX_IDX.

source

pub fn negative(idx: u32) -> Lit

Creates a new negated literal with a given index. Panics if idx > Var::MAX_IDX.

source

pub fn positive_with_error(idx: u32) -> Result<Lit, TypeError>

Creates a new positive literal with a given index. Panics if idx > Var::MAX_IDX.

source

pub fn negative_with_error(idx: u32) -> Result<Lit, TypeError>

Creates a new negated literal with a given index. Panics if idx > Var::MAX_IDX.

source

pub fn positive_unchecked(idx: u32) -> Lit

Creates a new positive literal with a given index. Does not perform any check on the index, therefore might produce an inconsistent variable. Only use this for performance reasons if you are sure that idx <= Var::MAX_IDX.

source

pub fn negative_unchecked(idx: u32) -> Lit

Creates a new negated literal with a given index. Does not perform any check on the index, therefore might produce an inconsistent variable. Only use this for performance reasons if you are sure that idx <= Var::MAX_IDX.

source

pub fn from_ipasir(val: c_int) -> Result<Lit, TypeError>

Create a literal from an IPASIR integer value. Returns an error if the value is zero or the index too high.

source

pub fn vidx(&self) -> usize

Gets the variable index of the literal

source

pub fn vidx32(&self) -> u32

Gets the 32bit variable index of the literal

source

pub fn lidx(&self) -> usize

Gets a literal representation for indexing data structures

source

pub fn var(&self) -> Var

Gets the variables that the literal corresponds to.

§Examples
let var = Var::new(5);
let lit = Lit::negative(5);
assert_eq!(var, lit.var());
source

pub fn is_pos(&self) -> bool

True if the literal is positive.

source

pub fn is_neg(&self) -> bool

True if the literal is negated.

source

pub fn to_ipasir(self) -> c_int

Converts the literal to an integer as accepted by the IPASIR API and similar. The IPASIR literal will have idx+1 and be negative if the literal is negated. Panics if the literal does not fit into a c_int.

source

pub fn to_ipasir_with_error(self) -> Result<c_int, TypeError>

Converts the literal to an integer as accepted by the IPASIR API and similar. The IPASIR literal will have idx+1 and be negative if the literal is negated. Returns Err(TypeError::IdxTooHigh(_, _)) if the literal does not fit into a c_int.

Trait Implementations§

source§

impl Add<u32> for Lit

Incrementing literals. This preserves the sign of the literal.

§

type Output = Lit

The resulting type after applying the + operator.
source§

fn add(self, rhs: u32) -> Self::Output

Performs the + operation. Read more
source§

impl Clone for Lit

source§

fn clone(&self) -> Lit

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Lit

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Display for Lit

Literals can be printed with the Display trait

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Extend<Lit> for Clause

source§

fn extend<T: IntoIterator<Item = Lit>>(&mut self, iter: T)

Extends a collection with the contents of an iterator. Read more
source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
source§

impl Extend<Lit> for DbTotalizer

source§

fn extend<T: IntoIterator<Item = Lit>>(&mut self, iter: T)

Extends a collection with the contents of an iterator. Read more
source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
source§

impl<UBE, LBE> Extend<Lit> for Double<UBE, LBE>
where UBE: BoundUpper + Extend<Lit> + 'static, LBE: BoundLower + Extend<Lit> + 'static,

source§

fn extend<T: IntoIterator<Item = Lit>>(&mut self, iter: T)

Extends a collection with the contents of an iterator. Read more
source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
source§

impl<CE> Extend<Lit> for Inverted<CE>
where CE: Encode + Extend<Lit> + 'static,

source§

fn extend<T: IntoIterator<Item = Lit>>(&mut self, iter: T)

Extends a collection with the contents of an iterator. Read more
source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
source§

impl Extend<Lit> for Pairwise

source§

fn extend<T: IntoIterator<Item = Lit>>(&mut self, iter: T)

Extends a collection with the contents of an iterator. Read more
source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
source§

impl Extend<Lit> for Totalizer

source§

fn extend<T: IntoIterator<Item = Lit>>(&mut self, iter: T)

Extends a collection with the contents of an iterator. Read more
source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
source§

impl FromIterator<Lit> for Assignment

source§

fn from_iter<T: IntoIterator<Item = Lit>>(iter: T) -> Self

Creates a value from an iterator. Read more
source§

impl FromIterator<Lit> for Clause

source§

fn from_iter<T: IntoIterator<Item = Lit>>(iter: T) -> Self

Creates a value from an iterator. Read more
source§

impl FromIterator<Lit> for DbTotalizer

source§

fn from_iter<T: IntoIterator<Item = Lit>>(iter: T) -> Self

Creates a value from an iterator. Read more
source§

impl<UBE, LBE> FromIterator<Lit> for Double<UBE, LBE>
where UBE: BoundUpper + From<Vec<Lit>> + 'static, LBE: BoundLower + From<Vec<Lit>> + 'static,

source§

fn from_iter<T: IntoIterator<Item = Lit>>(iter: T) -> Self

Creates a value from an iterator. Read more
source§

impl<CE> FromIterator<Lit> for Inverted<CE>
where CE: Encode + From<Vec<Lit>> + 'static,

source§

fn from_iter<T: IntoIterator<Item = Lit>>(iter: T) -> Self

Creates a value from an iterator. Read more
source§

impl FromIterator<Lit> for Pairwise

source§

fn from_iter<T: IntoIterator<Item = Lit>>(iter: T) -> Self

Creates a value from an iterator. Read more
source§

impl FromIterator<Lit> for Totalizer

source§

fn from_iter<T: IntoIterator<Item = Lit>>(iter: T) -> Self

Creates a value from an iterator. Read more
source§

impl Hash for Lit

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl Neg for Lit

Trait implementation allowing for negating literals with the unary - operator.

§

type Output = Lit

The resulting type after applying the - operator.
source§

fn neg(self) -> Lit

Performs the unary - operation. Read more
source§

impl Not for Lit

Trait implementation allowing for negating literals with the ! operator.

§

type Output = Lit

The resulting type after applying the ! operator.
source§

fn not(self) -> Lit

Performs the unary ! operation. Read more
source§

impl Ord for Lit

source§

fn cmp(&self, other: &Lit) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl PartialEq for Lit

source§

fn eq(&self, other: &Lit) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd for Lit

source§

fn partial_cmp(&self, other: &Lit) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Sub<u32> for Lit

Decrementing literals. This preserves the sign of the literal.

§

type Output = Lit

The resulting type after applying the - operator.
source§

fn sub(self, rhs: u32) -> Self::Output

Performs the - operation. Read more
source§

impl Copy for Lit

source§

impl Eq for Lit

source§

impl StructuralPartialEq for Lit

Auto Trait Implementations§

§

impl RefUnwindSafe for Lit

§

impl Send for Lit

§

impl Sync for Lit

§

impl Unpin for Lit

§

impl UnwindSafe for Lit

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V