From 862e31634119e426779fc73e61e3f5399edfe955 Mon Sep 17 00:00:00 2001 From: AlpMimaroglu Date: Tue, 7 Jan 2025 21:05:54 +0100 Subject: [PATCH] switch to IntoIterator and add doc test --- src/solvers/mod.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/solvers/mod.rs b/src/solvers/mod.rs index 25a20c6..9edebf2 100644 --- a/src/solvers/mod.rs +++ b/src/solvers/mod.rs @@ -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) -> 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) -> Self where Self: Sized, {