From babb7b7055ec4a8014f5f252c2a02f9dc7a81e5a Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sun, 21 Feb 2016 20:17:27 +0100 Subject: [PATCH] doc: libimagutil: Add documentation of the generate_variants() util --- doc/src/03000-lib-util.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/doc/src/03000-lib-util.md b/doc/src/03000-lib-util.md index 42b128c2..6c397ba6 100644 --- a/doc/src/03000-lib-util.md +++ b/doc/src/03000-lib-util.md @@ -53,3 +53,19 @@ printing the error trace to the debug output stream. [Error][a_errorkind]: Some A-error text ``` +## Variant generator {#sec:libutil:vargen} + +The `generate_variants()` function can be used to generate variants of a base +vector value. + +```{#lst:vargen:exampleuse .rust .numberLines caption="Variant generation"} +let base = 1; +let vars = vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; +let res = generate_variants(base, vars, &|base, var| base + var); + +assert!(res == vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) +``` + +As shown in @lst:vargen:exampleuse (from the tests), can this function +be used to generate values from a base value. +