Fix & fmt & ci
This commit is contained in:
parent
656890c1be
commit
358175fd33
14
.drone.yml
Normal file
14
.drone.yml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
kind: pipeline
|
||||||
|
name: default
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: build
|
||||||
|
image: rust
|
||||||
|
commands:
|
||||||
|
- cargo build --verbose --all
|
||||||
|
|
||||||
|
- name: fmt-check
|
||||||
|
image: rust
|
||||||
|
commands:
|
||||||
|
- rustup component add rustfmt
|
||||||
|
- cargo fmt --all -- --check
|
@ -12,10 +12,6 @@ keywords = ["constraint", "finite", "domain", "puzzle", "sudoku"]
|
|||||||
categories = ["science"]
|
categories = ["science"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[[bin]]
|
|
||||||
name = "run"
|
|
||||||
path = "./bin/run.rs"
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bit-set = "0.4"
|
bit-set = "0.4"
|
||||||
num-rational = { version = "0.1", default-features = false }
|
num-rational = { version = "0.1", default-features = false }
|
||||||
|
@ -4,7 +4,7 @@ use num_rational::Ratio;
|
|||||||
use num_traits::Zero;
|
use num_traits::Zero;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
use crate::{Constraint, Error, linexpr::LinExpr, PsResult, PuzzleSearch, Val, VarToken};
|
use crate::{linexpr::LinExpr, Constraint, Error, PsResult, PuzzleSearch, Val, VarToken};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Equality {
|
pub struct Equality {
|
||||||
|
@ -13,9 +13,9 @@ use std::ops;
|
|||||||
|
|
||||||
pub use constraint::Constraint;
|
pub use constraint::Constraint;
|
||||||
pub use error::Error;
|
pub use error::Error;
|
||||||
|
pub use linexpr::LinExpr;
|
||||||
pub use puzzle::Puzzle;
|
pub use puzzle::Puzzle;
|
||||||
pub use puzzle::PuzzleSearch;
|
pub use puzzle::PuzzleSearch;
|
||||||
pub use linexpr::LinExpr;
|
|
||||||
|
|
||||||
/// A puzzle variable token.
|
/// A puzzle variable token.
|
||||||
#[derive(Copy, Clone, Debug, Eq, Hash, PartialEq)]
|
#[derive(Copy, Clone, Debug, Eq, Hash, PartialEq)]
|
||||||
@ -27,7 +27,6 @@ pub type Val = i32;
|
|||||||
/// The type of the coefficients in a linear expression.
|
/// The type of the coefficients in a linear expression.
|
||||||
pub type Coef = Rational32;
|
pub type Coef = Rational32;
|
||||||
|
|
||||||
|
|
||||||
/// A result during a puzzle solution search (Err = contradiction).
|
/// A result during a puzzle solution search (Err = contradiction).
|
||||||
pub type PsResult<T> = Result<T, Error>;
|
pub type PsResult<T> = Result<T, Error>;
|
||||||
|
|
||||||
|
@ -38,13 +38,13 @@ impl From<&[Val]> for Candidates {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl <const N: usize> From<&[Val; N]> for Candidates {
|
impl<const N: usize> From<&[Val; N]> for Candidates {
|
||||||
fn from(set: &[Val; N]) -> Self {
|
fn from(set: &[Val; N]) -> Self {
|
||||||
Candidates::Set(Rc::new(set.iter().copied().collect()))
|
Candidates::Set(Rc::new(set.iter().copied().collect()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl <const N: usize> From<[Val; N]> for Candidates {
|
impl<const N: usize> From<[Val; N]> for Candidates {
|
||||||
fn from(set: [Val; N]) -> Self {
|
fn from(set: [Val; N]) -> Self {
|
||||||
Candidates::Set(Rc::new(set.into_iter().collect()))
|
Candidates::Set(Rc::new(set.into_iter().collect()))
|
||||||
}
|
}
|
||||||
@ -200,7 +200,11 @@ impl Puzzle {
|
|||||||
/// let mut send_more_money = puzzle_solver::Puzzle::new();
|
/// let mut send_more_money = puzzle_solver::Puzzle::new();
|
||||||
/// send_more_money.new_vars(8, &[0,1,2,3,4,5,6,7,8,9]);
|
/// send_more_money.new_vars(8, &[0,1,2,3,4,5,6,7,8,9]);
|
||||||
/// ```
|
/// ```
|
||||||
pub fn new_vars<C: Into<Candidates> + Clone>(&mut self, n: usize, candidates: C) -> Vec<VarToken> {
|
pub fn new_vars<C: Into<Candidates> + Clone>(
|
||||||
|
&mut self,
|
||||||
|
n: usize,
|
||||||
|
candidates: C,
|
||||||
|
) -> Vec<VarToken> {
|
||||||
let mut vars = Vec::with_capacity(n);
|
let mut vars = Vec::with_capacity(n);
|
||||||
for _ in 0..n {
|
for _ in 0..n {
|
||||||
vars.push(self.new_var(candidates.clone()));
|
vars.push(self.new_var(candidates.clone()));
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use std::ops::{Bound, RangeBounds};
|
|
||||||
use ranges::GenericRange;
|
|
||||||
use crate::Val;
|
use crate::Val;
|
||||||
|
use ranges::GenericRange;
|
||||||
|
use std::ops::{Bound, RangeBounds};
|
||||||
|
|
||||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||||
pub struct Ranges {
|
pub struct Ranges {
|
||||||
|
Loading…
Reference in New Issue
Block a user