日本語

Expr

Expr<S, T> is an expression over the signals of S that evaluates to a T in the browser.

Building expressions

+, -, *, and % work on i32, i64, and f64, / on f64, and ! on bool.

ItemSummary
Expr::litA constant value, serialized to JSON once at render time.
if_elseThe expression then while cond is true, and otherwise while it is false.
Expr::nowThe browser's current time, in milliseconds since the Unix epoch.
Expr::random_belowA random integer from 0 up to but not including bound, drawn in the browser.
atThe field field of the struct this expression evaluates to.
withA copy of this struct with field replaced by value.
let_inThe expression body builds from this value, which is evaluated once however often body uses it.
let_in_stmtA statement that runs body with this value, computed once when the statement runs.

Comparisons and logic

ItemSummary
equalsWhether this value equals rhs.
not_equalsWhether this value differs from rhs, comparing JSON forms.
gtWhether this value is strictly greater than rhs.
geWhether this value is greater than or equal to rhs.
ltWhether this value is strictly less than rhs.
leWhether this value is less than or equal to rhs.
andWhether both this value and rhs are true.
orWhether this value or rhs is true.

Numbers and text

ItemSummary
minThe smaller of this value and rhs.
maxThe larger of this value and rhs.
to_f64This number as an f64, which holds every i32 exactly.
to_fixedThis number as text with digits digits after the point.
floorThe largest whole number at or below this one.
ceilThe smallest whole number at or above this one.
roundThe nearest whole number, with a halfway value rounded up.
log10The base 10 logarithm of this number.
powThis number raised to the power exponent.
formatThis number as text in format, with its digits grouped and its affixes.
NumberFormatHow format writes a number: decimals, separators, and affixes.
pluralThe form that form gives for the plural category of this number in locale.
PluralCategoryA plural category of the Unicode CLDR, which Intl.PluralRules picks for a number.
IntlLocaleA locale that the browser's Intl writes text for, and the first HTML matches.
TimestampA point in time, in milliseconds since the Unix epoch.
format_dateThis time written in format with the browser's Intl.DateTimeFormat.
DateFormatHow format_date writes a Timestamp: a locale, styles, and a time zone.
relative_toThis time relative to now in locale, such as 3 minutes ago.
to_textThis value as display text, as JavaScript's String writes it.
labelThe text label gives for this value's variant, with every variant covered.
VariantsAn enum with #[derive(Segment)], whose variants the derive lists.
concatThis string with rhs appended.
trimThis string without leading and trailing whitespace.
to_lowercaseThis string in lowercase.
to_uppercaseThis string in uppercase.
containsWhether needle occurs in this string.
starts_withWhether this string starts with prefix.
char_countThe number of Unicode scalar values, as Rust's chars().count().
all_charsWhether every character of this string is in class, true for an empty string.
any_charWhether some character of this string is in class, false for an empty string.
CharClassA set of ASCII characters that all_chars and any_char test for.

Lists and options

ItemSummary
lenThe number of items.
nthThe item at index, or None past either end.
is_someWhether this option holds a value.
is_noneWhether this option is None.
unwrap_orThe held value, or default for None.
someThis value wrapped in Some.