Skip to content

Commit

Permalink
switch to IntoIterator and add doc test
Browse files Browse the repository at this point in the history
  • Loading branch information
AlpMimaroglu committed Jan 7, 2025
1 parent f7375e1 commit 862e316
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/solvers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,20 @@ pub trait SolverModel {
}

/// Takes a model and adds a list of constraints to it
fn with_all(mut self, constraints: impl Iterator<Item = Constraint>) -> Self
///
/// # Examples
/// ```rust
/// use good_lp::*;
/// let mut vars = variables!();
/// let x = vars.add_variable(); // unbounded variable
/// let result = vars.maximise(x)
/// .using(default_solver)
/// .with_all([constraint!(x >= 1), constraint!(x <= 10)])
/// .solve()
/// .expect("example model, trivial to solve"); //
/// assert_eq!(result.eval(&x), 10.);
/// ```
fn with_all(mut self, constraints: impl IntoIterator<Item = Constraint>) -> Self
where
Self: Sized,
{
Expand Down

0 comments on commit 862e316

Please # to comment.