pub fn random_int64(args: &HashMap<String, Value>) -> Result<Value>Expand description
A Tera function to generate a random signed 64-bit integer.
The start parameter takes a signed 64-bit integer to indicate the beginning of the
range (inclusive). If start is not passed in, it defaults to i64::MIN.
The end parameter also takes an signed 64-bit integer indicating the end of the range,
which is also inclusive. An inclusive range allows i64::MAX to be sampled where an
exclusive range does not. If end is not passed in, it defaults to i64::MAX.
It is possible to pass in both start and end, just one of them, or neither in order to
sample across the entire i64 space.
§Example usage
ⓘ
use tera::{Context, Tera};
use tera_rand::random_int64;
let mut tera: Tera = Tera::default();
tera.register_function("random_int64", random_int64);
let context: Context = Context::new();
// bound by both start and end
let rendered: String = tera
.render_str("{{ random_int64(start=-128, end=127) }}", &context)
.unwrap();
// bound by just start
let rendered: String = tera
.render_str("{{ random_int64(start=-1) }}", &context)
.unwrap();
// bound by just end
let rendered: String = tera
.render_str("{{ random_int64(end=0) }}", &context)
.unwrap();
// bound by neither start nor end
let rendered: String = tera
.render_str("{{ random_int64() }}", &context)
.unwrap();