[][src]Struct varisat::Var

#[repr(transparent)]
pub struct Var { index: u32, }

A boolean variable.

A boolean value is represented by an index. Internally these are 0-based, i.e. the first variable has the index 0. For user IO a 1-based index is used, to allow denoting negated variables using negative integers. This convention is also used in the DIMACS CNF format.

Creating a variable with an index larger than Var::max_var().index() is unsupported. This might panic or be interpreted as a different variable.

Fields

index: u32

Methods

impl Var[src]

pub fn from_dimacs(number: isize) -> Var[src]

Creates a variable from a 1-based index as used in the DIMCAS CNF encoding.

The parameter must be positive and may not represent a variable past Var::max_var().

pub fn from_index(index: usize) -> Var[src]

Creates a variable from a 0-based index.

The index may not represent a variable past Var::max_var().

pub fn to_dimacs(self) -> isize[src]

The 1-based index representing this variable in the DIMACS CNF encoding.

pub const fn index(self) -> usize[src]

The 0-based index representing this variable.

pub const fn max_var() -> Var[src]

The variable with largest index that is supported.

This is less than the backing integer type supports. This enables storing a variable index and additional bits (as in Lit) or sentinel values in a single word.

pub const fn max_count() -> usize[src]

Largest number of variables supported.

This is exactly Var::max_var().index() + 1.

pub fn lit(self, polarity: bool) -> Lit[src]

Creates a literal from this var and a bool that is true when the literal is positive.

Shortcut for Lit::from_var(var, polarity).

pub fn positive(self) -> Lit[src]

Creates a positive literal from this var.

Shortcut for Lit::positive(var).

pub fn negative(self) -> Lit[src]

Creates a negative literal from this var.

Shortcut for Lit::negative(var).

Trait Implementations

impl Copy for Var[src]

impl Ord for Var[src]

fn max(self, other: Self) -> Self1.21.0[src]

Compares and returns the maximum of two values. Read more

fn min(self, other: Self) -> Self1.21.0[src]

Compares and returns the minimum of two values. Read more

fn clamp(self, min: Self, max: Self) -> Self[src]

🔬 This is a nightly-only experimental API. (clamp)

Restrict a value to a certain interval. Read more

impl Clone for Var[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for Var[src]

Uses the 1-based DIMACS CNF encoding.

impl PartialEq<Var> for Var[src]

impl From<Var> for Lit[src]

impl PartialOrd<Var> for Var[src]

impl Hash for Var[src]

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

Feeds a slice of this type into the given [Hasher]. Read more

impl Eq for Var[src]

impl Display for Var[src]

Uses the 1-based DIMACS CNF encoding.

Auto Trait Implementations

impl Send for Var

impl Sync for Var

Blanket Implementations

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<Reference, Outer, OuterFieldType, Inner> HasPart<Nested<Outer, Inner>> for Reference where
    Inner: Part,
    Outer: Part<PartType = Field<OuterFieldType>>,
    OuterFieldType: HasPart<Inner, RawTarget = OuterFieldType> + PartialRefTarget + ?Sized,
    Reference: HasPart<Outer> + ?Sized