Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clippy fixes #36

Merged
merged 5 commits into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/libpcp/logic/boolean_neg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub struct BooleanNeg<VStore> {

impl<VStore> BooleanNeg<VStore> {
pub fn new(b: Boolean<VStore>) -> Self {
BooleanNeg { b: b }
BooleanNeg { b }
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/libpcp/logic/conjunction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub struct Conjunction<VStore> {

impl<VStore> Conjunction<VStore> {
pub fn new(fs: Vec<Formula<VStore>>) -> Self {
Conjunction { fs: fs }
Conjunction { fs }
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/libpcp/logic/disjunction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub struct Disjunction<VStore> {

impl<VStore> Disjunction<VStore> {
pub fn new(fs: Vec<Formula<VStore>>) -> Self {
Disjunction { fs: fs }
Disjunction { fs }
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/libpcp/propagation/reactors/indexed_deps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl IndexedDeps {
self.num_events * var + ev.to_index()
}

fn deps_of_mut<'a, E>(&'a mut self, var: usize, ev: E) -> &'a mut Vec<usize>
fn deps_of_mut<E>(&mut self, var: usize, ev: E) -> &mut Vec<usize>
where
E: EventIndex,
{
Expand All @@ -56,7 +56,7 @@ impl IndexedDeps {
impl Reactor for IndexedDeps {
fn new(num_vars: usize, num_events: usize) -> IndexedDeps {
IndexedDeps {
num_events: num_events,
num_events,
num_subscriptions: 0,
deps: FromIterator::from_iter(repeat(vec![]).take(num_vars * num_events)),
}
Expand Down
6 changes: 3 additions & 3 deletions src/libpcp/propagation/schedulers/relaxed_fifo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,20 @@ impl Scheduler for RelaxedFifo {
RelaxedFifo {
inside_queue: BitSet::with_capacity(capacity),
queue: VecDeque::with_capacity(capacity),
capacity: capacity,
capacity,
}
}

fn schedule(&mut self, idx: usize) {
assert!((idx as usize) < self.capacity);
assert!(idx < self.capacity);
if !self.inside_queue.contains(idx) {
self.inside_queue.insert(idx);
self.queue.push_back(idx);
}
}

fn unschedule(&mut self, idx: usize) {
assert!((idx as usize) < self.capacity);
assert!(idx < self.capacity);
if self.inside_queue.contains(idx) {
let queue_idx = self.queue.iter().position(|&e| e == idx);
assert!(queue_idx.is_some());
Expand Down
16 changes: 8 additions & 8 deletions src/libpcp/propagation/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,20 +85,20 @@ impl<VStore, Event, R, S> Store<VStore, Event, R, S> {
}

impl<VStore, Event, R, S> DisplayStateful<(Model, VStore)> for Store<VStore, Event, R, S> {
fn display(&self, &(ref model, ref vstore): &(Model, VStore)) {
fn display(&self, (model, vstore): &(Model, VStore)) {
let mut subsumed = vec![];
let mut unknown = vec![];
let mut unsatisfiable = vec![];
for (i, p) in self.propagators.iter().enumerate() {
match p.is_subsumed(&vstore) {
match p.is_subsumed(vstore) {
False => unsatisfiable.push(i),
True => subsumed.push(i),
Unknown => unknown.push(i),
};
}
self.display_constraints(&model, unsatisfiable, "unsatisfiable:");
self.display_constraints(&model, subsumed, "subsumed:");
self.display_constraints(&model, unknown, "unknown:");
self.display_constraints(model, unsatisfiable, "unsatisfiable:");
self.display_constraints(model, subsumed, "subsumed:");
self.display_constraints(model, unknown, "unknown:");
}
}

Expand Down Expand Up @@ -209,13 +209,13 @@ where

impl<VStore, Event, R, S> Index<usize> for Store<VStore, Event, R, S> {
type Output = Box<dyn PropagatorConcept<VStore, Event> + 'static>;
fn index<'a>(&'a self, index: usize) -> &'a Self::Output {
fn index(&self, index: usize) -> &Self::Output {
&self.propagators[index]
}
}

impl<VStore, Event, R, S> IndexMut<usize> for Store<VStore, Event, R, S> {
fn index_mut<'a>(&'a mut self, index: usize) -> &'a mut Self::Output {
fn index_mut(&mut self, index: usize) -> &mut Self::Output {
&mut self.propagators[index]
}
}
Expand Down Expand Up @@ -299,7 +299,7 @@ where
S: Scheduler,
{
fn new(cstore: Store<VStore, Event, R, S>) -> Self {
FrozenStore { cstore: cstore }
FrozenStore { cstore }
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/libpcp/propagators/all_equal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ where
}
AllEqual {
conj: Conjunction::new(props),
vars: vars,
vars,
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/libpcp/propagators/cmp/x_eq_y.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub struct XEqY<VStore> {

impl<VStore> XEqY<VStore> {
pub fn new(x: Var<VStore>, y: Var<VStore>) -> Self {
XEqY { x: x, y: y }
XEqY { x, y }
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/libpcp/propagators/cmp/x_eq_y_mul_z.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub struct XEqYMulZ<VStore> {

impl<VStore> XEqYMulZ<VStore> {
pub fn new(x: Var<VStore>, y: Var<VStore>, z: Var<VStore>) -> Self {
XEqYMulZ { x: x, y: y, z: z }
XEqYMulZ { x, y, z }
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/libpcp/propagators/cmp/x_greater_y_plus_z.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub struct XGreaterYPlusZ<VStore> {

impl<VStore> XGreaterYPlusZ<VStore> {
pub fn new(x: Var<VStore>, y: Var<VStore>, z: Var<VStore>) -> Self {
XGreaterYPlusZ { x: x, y: y, z: z }
XGreaterYPlusZ { x, y, z }
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/libpcp/propagators/cmp/x_less_y.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub struct XLessY<VStore> {

impl<VStore> XLessY<VStore> {
pub fn new(x: Var<VStore>, y: Var<VStore>) -> XLessY<VStore> {
XLessY { x: x, y: y }
XLessY { x, y }
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/libpcp/propagators/cmp/x_less_y_plus_z.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub struct XLessYPlusZ<VStore> {

impl<VStore> XLessYPlusZ<VStore> {
pub fn new(x: Var<VStore>, y: Var<VStore>, z: Var<VStore>) -> Self {
XLessYPlusZ { x: x, y: y, z: z }
XLessYPlusZ { x, y, z }
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/libpcp/propagators/cmp/x_neq_y.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub struct XNeqY<VStore> {

impl<VStore> XNeqY<VStore> {
pub fn new(x: Var<VStore>, y: Var<VStore>) -> Self {
XNeqY { x: x, y: y }
XNeqY { x, y }
}
}

Expand Down
16 changes: 8 additions & 8 deletions src/libpcp/propagators/cumulative.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ impl<VStore> Cumulative<VStore> {
assert_eq!(tasks, durations.len());
assert_eq!(tasks, resources.len());
Cumulative {
starts: starts,
durations: durations,
resources: resources,
capacity: capacity,
starts,
durations,
resources,
capacity,
intermediate: vec![],
}
}
Expand Down Expand Up @@ -163,10 +163,10 @@ mod test {
capacity: Interval<i32>,
) -> Self {
CumulativeTest {
starts: starts,
durations: durations,
resources: resources,
capacity: capacity,
starts,
durations,
resources,
capacity,
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/libpcp/propagators/distinct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ where
}
Distinct {
conj: Conjunction::new(props),
vars: vars,
vars,
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/libpcp/search/branch_and_bound.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ where
{
pub fn new(mode: Mode, var: Var<VStore>, child: C) -> Self {
BranchAndBound {
mode: mode,
var: var,
mode,
var,
value: None,
child: child,
child,
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/libpcp/search/branching/brancher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ pub struct Brancher<Var, Val, D> {
impl<Var, Val, D> Brancher<Var, Val, D> {
pub fn new(var_selector: Var, val_selector: Val, distributor: D) -> Self {
Brancher {
var_selector: var_selector,
val_selector: val_selector,
distributor: distributor,
var_selector,
val_selector,
distributor,
}
}
}
Expand Down
5 changes: 1 addition & 4 deletions src/libpcp/search/debugger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@ pub struct Debugger<C> {

impl<C> Debugger<C> {
pub fn new(model: Model, child: C) -> Debugger<C> {
Debugger {
model: model,
child: child,
}
Debugger { model, child }
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/libpcp/search/engine/all_solution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub struct AllSolution<C> {

impl<C> AllSolution<C> {
pub fn new(child: C) -> Self {
AllSolution { child: child }
AllSolution { child }
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/libpcp/search/engine/one_solution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ where
pub fn new(child: C) -> OneSolution<C, Q, Space> {
OneSolution {
queue: Q::empty(),
child: child,
child,
started_exploration: false,
phantom_space: PhantomData,
}
Expand Down
7 changes: 2 additions & 5 deletions src/libpcp/search/monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub trait SearchMonitor<Space: Freeze> {
&Satisfiable => self.on_solution(space),
&Unsatisfiable => self.on_failure(space),
&EndOfSearch => self.on_end_of_search(space),
&Unknown(ref b) if b.is_empty() => self.on_prune(space),
Unknown(b) if b.is_empty() => self.on_prune(space),
&Unknown(_) => self.on_unknown(space),
}
}
Expand All @@ -45,10 +45,7 @@ pub struct Monitor<'a, M: 'a, C> {

impl<'a, M, C> Monitor<'a, M, C> {
pub fn new(monitor: &'a mut M, child: C) -> Monitor<'a, M, C> {
Monitor {
monitor: monitor,
child: child,
}
Monitor { monitor, child }
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/libpcp/search/propagation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub struct Propagation<C> {

impl<C> Propagation<C> {
pub fn new(child: C) -> Propagation<C> {
Propagation { child: child }
Propagation { child }
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/libpcp/search/search_tree_visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ where
let name = match self {
&Satisfiable => "Satisfiable",
&Unsatisfiable => "Unsatisfiable",
&Unknown(ref branches) if branches.is_empty() => "Pruned",
Unknown(branches) if branches.is_empty() => "Pruned",
&Unknown(_) => "Unknown",
&EndOfSearch => "End of search",
};
Expand All @@ -61,7 +61,7 @@ where
match (self, other) {
(&Satisfiable, &Satisfiable) => true,
(&Unsatisfiable, &Unsatisfiable) => true,
(&Unknown(ref b1), &Unknown(ref b2)) if b1.is_empty() && b2.is_empty() => true,
(Unknown(b1), Unknown(b2)) if b1.is_empty() && b2.is_empty() => true,
(&Unknown(_), &Unknown(_)) => panic!("Cannot compare unknown status."),
(&EndOfSearch, &EndOfSearch) => true,
(_, _) => false,
Expand Down
4 changes: 2 additions & 2 deletions src/libpcp/search/space.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ pub struct Space<VStore, CStore, Restoration> {
impl<VStore, CStore, Restoration> Space<VStore, CStore, Restoration> {
pub fn new(vstore: VStore, cstore: CStore) -> Self {
Space {
vstore: vstore,
cstore: cstore,
vstore,
cstore,
phantom_restoration: PhantomData,
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/libpcp/search/stop_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ pub struct StopNode<C> {
impl<C> StopNode<C> {
pub fn new(limit: usize, child: C) -> StopNode<C> {
StopNode {
child: child,
limit: limit,
child,
limit,
nodes_explored: 0,
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/libpcp/term/addition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ where
Domain: Collection<Item = Bound>,
{
pub fn new(x: Var<VStore>, v: Bound) -> Self {
Addition { x: x, v: v }
Addition { x, v }
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/libpcp/term/constant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub struct Constant<V> {

impl<V> Constant<V> {
pub fn new(value: V) -> Constant<V> {
Constant { value: value }
Constant { value }
}
}

Expand Down Expand Up @@ -89,7 +89,7 @@ mod test {
let dom0_4 = (0, 4).to_interval();
let mut store = VStore::empty();
let x = Box::new(store.alloc(dom0_10)) as Var<VStore>;
let c = Box::new(Constant::new(5 as i32)) as Var<VStore>;
let c = Box::new(Constant::new(5_i32)) as Var<VStore>;

let x_less_c = XLessY::new(x.bclone(), c);
test_propagation(
Expand Down
2 changes: 1 addition & 1 deletion src/libpcp/term/identity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub struct Identity<Domain> {
impl<Domain> Identity<Domain> {
pub fn new(idx: usize) -> Identity<Domain> {
Identity {
idx: idx,
idx,
phantom: PhantomData,
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/libpcp/term/sum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub struct Sum<VStore> {

impl<VStore> Sum<VStore> {
pub fn new(vars: Vec<Var<VStore>>) -> Self {
Sum { vars: vars }
Sum { vars }
}
}

Expand Down
Loading