Struct pcp::term::constant::Constant

source ·
pub struct Constant<V> { /* private fields */ }

Implementations§

Examples found in repository?
src/libpcp/search/branch_and_bound.rs (line 70)
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
  fn enter(&mut self, mut current: Space<VStore, CStore, R>)
    -> (<Space<VStore, CStore, R> as Freeze>::FrozenState, Status<Space<VStore, CStore, R>>)
  {
    if let Some(bound) = self.value.clone() {
      let bound = Box::new(Constant::new(bound)) as Var<VStore>;
      match self.mode {
        Mode::Minimize => current.cstore.alloc(Box::new(XLessY::new(self.var.bclone(), bound.bclone()))),
        Mode::Maximize => current.cstore.alloc(Box::new(x_greater_y(self.var.bclone(), bound.bclone()))),
      };
    }
    let (mut immutable_state, status) = self.child.enter(current);
    if status == Satisfiable {
      let space = immutable_state.unfreeze();
      self.value = Some(self.var.read(&space.vstore).lower());
      immutable_state = space.freeze();
    }
    (immutable_state, status)
  }
More examples
Hide additional examples
src/libpcp/search/branching/binary_split.rs (line 40)
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
  fn distribute(&mut self, space: Space<VStore, CStore, R>, var_idx: usize, val: Bound) ->
    (<Space<VStore, CStore, R> as Freeze>::FrozenState, Vec<Branch<Space<VStore, CStore, R>>>)
  {
    // See notes in Enumerate::distribute.
    Branch::distribute(space,
      vec![
        Box::new(move |space: &mut Space<VStore, CStore, R>| {
          let x = Box::new(Identity::<Domain>::new(var_idx)) as Var<VStore>;
          let v = Box::new(Constant::new(val)) as Var<VStore>;
          let x_less_v = x_leq_y::<_,_,Bound>(x.bclone(), v.bclone());
          space.cstore.alloc(Box::new(x_less_v));
        }),
        Box::new(move |space: &mut Space<VStore, CStore, R>| {
          let x = Box::new(Identity::<Domain>::new(var_idx)) as Var<VStore>;
          let v = Box::new(Constant::new(val)) as Var<VStore>;
          let x_geq_v = x_greater_y(x, v);
          space.cstore.alloc(Box::new(x_geq_v));
        })
      ]
    )
  }
src/libpcp/search/branching/enumerate.rs (line 42)
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
  fn distribute(&mut self, space: Space<VStore, CStore, R>, var_idx: usize, val: Bound) ->
    (<Space<VStore, CStore, R> as Freeze>::FrozenState, Vec<Branch<Space<VStore, CStore, R>>>)
  {
    // Note that `Copy` on `Bound` should not be mandatory.
    // This is a problem generated by the Rust issue #28796, because we cannot box (and thus return) closures that contain moved values.
    // This is also why we have redundant code in both branches, we can only pass value that can be copied to the closures (here `var_idx` and `val`).
    Branch::distribute(space,
      vec![
        Box::new(move |space: &mut Space<VStore, CStore, R>| {
          let x = Box::new(Identity::<Domain>::new(var_idx)) as Var<VStore>;
          let v = Box::new(Constant::new(val)) as Var<VStore>;
          let x_eq_v = XEqY::new(x.bclone(), v.bclone());
          space.cstore.alloc(Box::new(x_eq_v));
        }),
        Box::new(move |space: &mut Space<VStore, CStore, R>| {
          let x = Box::new(Identity::<Domain>::new(var_idx)) as Var<VStore>;
          let v = Box::new(Constant::new(val)) as Var<VStore>;
          let x_neq_v = XNeqY::new(x, v);
          space.cstore.alloc(Box::new(x_neq_v));
        })
      ]
    )
  }

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.