From 4a848be02cefd9739457ca552bbdbc56123c68bb Mon Sep 17 00:00:00 2001 From: Mohammed Ghannam Date: Mon, 29 Jul 2024 22:31:40 +0200 Subject: [PATCH] Document example with comments instead --- src/lib.rs | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 9554a89..15d1626 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,8 +1,8 @@ //! Safe Rust bindings for the SoPlex linear programming solver. //! -//! # Creating a model -//! You can create an LP model using the `add_col` and the `add_row` methods on the `Model`. -//! ``` +//! # Example +//! ```rust +//! // You can create an LP model using the `add_col` and the `add_row` methods on the `Model`. //! use soplex_rs::*; //! //! let mut lp = Model::new(); @@ -14,22 +14,18 @@ //! let row = lp.add_row(vec![1.0, 1.0], 1.0, 5.0); //! assert_eq!(lp.num_cols(), 2); //! assert_eq!(lp.num_rows(), 1); -//!``` //! -//! # Solving and getting the result -//! When calling `optimize` you get back a `SolvedModel` where you can query information about the solution -//! and basis status of columns and rows. -//!```rust +//! // When calling `optimize` you get back a `SolvedModel` where you can query information about the solution +//! // and basis status of columns and rows. //! let lp = lp.optimize(); //! let result = lp.status(); //! assert_eq!(result, Status::Optimal); //! assert!((lp.obj_val() - 5.0).abs() < 1e-6); -//! ``` //! -//! # Updating the model and resolving -//! After solving you need to return the `SolvedModel` object to a `Model` object as in -//! the example below. -//! ```rust +//! +//! // After solving you need to return the `SolvedModel` object to a `Model` object as in +//! // the example below. +//! //! let mut lp = Model::from(lp); // Convert the solved model back to a mutable one //! lp.remove_row(row); //! assert_eq!(lp.num_rows(), 0);