MCPcopy Create free account
hub / github.com/daniel-e/rustml / add_values

Method add_values

src/octave.rs:204–215  ·  view source on GitHub ↗

Adds the string to the Octave script. At the end of the line a semicolon is appended. If the string contains a dollar sign followed by a number `i` (e.g. `$1` or `$12`) this placeholder will be replaced by the value that is stored in the vector `vals` at index `i-1`. # Example ``` # extern crate rustml; use rustml::octave::*; # pub fn main() { let s = builder().add_values("x = $1 + $2", &[5,

(&self, s: &str, vals: &[T])

Source from the content-addressed store, hash-verified

202 /// # }
203 /// ```
204 pub fn add_values<T: fmt::Display>(&self, s: &str, vals: &[T]) -> OctaveScriptBuilder {
205
206 let mut t = s.to_string();
207 let n = vals.len();
208
209 for i in (0..n) {
210 let p = format!("${}", i + 1);
211 let v = format!("{}", vals[i]);
212 t = t.replace(&p, &v);
213 }
214 self.add(&t)
215 }
216
217 pub fn octave_bin(&self, path: &str) -> OctaveScriptBuilder {
218 OctaveScriptBuilder {

Callers 1

mainFunction · 0.80

Calls 3

to_stringMethod · 0.80
lenMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected