Expand description

A value expression can be as simple as @name to get the value of a parameter, but more complicated expressions, including function calls, are also allowed.

Value expressions

A parameter can be used in an expression preceded by an @ sign.

<h1>@name</h1>

If a parameter is a struct or a trait object, its fields or methods can be used, and if it is a callable, it can be called.

<p>The user @user.name has email @user.get_email().</p>
<p>A function result is @function(with, three, arguments).</p>

Standard function and macros can also be used, e.g. for specific formatting needs:

<p>The value is @format!("{:.1}", float_value).</p>

If more complex expressions are needed, they can be put in parenthesis.

<p>The sum @a+3 is @(a+3).</p>

Anything is allowed in parenthesis, as long as parenthesis, brackets and string quotes are balanced. Note that this also applies to the parenthesis of a function call or the brackets of an index, so complex things like the following are allowed:

<p>Index: @myvec[t.map(|s| s.length()).unwrap_or(0)].</p>
<p>Argument: @call(a + 3, |t| t.something()).</p>