-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Labels
ideaMy original ideaMy original idea
Description
Clauses only refer to properties. We don't need mutual references!
Approach
- reorganize primitive types
- move
vars
fromAssignStack
toClauseDB
orstatic mut
❗ - move out
heap
ofAssignStack
- change the type of
clause.lits
fromVec<Lit>
toVec<&Var<'a>>
Let's dive into the unsafe
hell
There's no mutable reference!
#![allow(static_mut_refs)]
static mut VECTOR: Vec<usize> = Vec::new();
pub trait VarIF {
fn push(&self, x: usize);
fn get(&self) -> usize;
fn set(&self, x: usize);
fn increment(&self, offset: usize);
}
struct Var(usize);
impl VarIF for Var {
fn push(&self, x: usize) {
unsafe {
VECTOR.push(x);
}
}
fn get(&self) -> usize {
unsafe { VECTOR[self.0] }
}
fn set(&self, x: usize) {
unsafe {
VECTOR[self.0] = x;
}
}
fn increment(&self, offset: usize) {
unsafe {
VECTOR[self.0] += offset;
}
}
}
fn main() {
Var(0).push(0);
println!("{}", Var(0).get());
Var(0).increment(2);
println!("{}", Var(0).get());
}
Metadata
Metadata
Assignees
Labels
ideaMy original ideaMy original idea