Skip to main content

Crate ferrovue_core

Crate ferrovue_core 

Source
Expand description

The primitives ferrovue’s runtime crates share: Vue’s HTML escaping, and numbers written as JavaScript writes them.

§Example

let mut out = String::from("<p>");
ferrovue::escape_into(&mut out, "Tom & Jerry");
out.push(' ');
ferrovue::push_number(&mut out, 0.1 + 0.2);
out.push_str("</p>");
assert_eq!(out, "<p>Tom &amp; Jerry 0.30000000000000004</p>");

Structs§

Js
A number written as JavaScript writes it, for format! in generated code: ${n} in a template literal, "#" + n, n.toString().

Functions§

escape_into
escapeHtml: ", &, ', < and >, and nothing else.
js_max
Math.max of two numbers: NaN if either is, where Rust’s f64::max ignores a NaN.
js_min
Math.min of two numbers: NaN if either is, where Rust’s f64::min ignores a NaN.
js_round
Math.round: the nearest integer, a half rounding up toward +∞ (-2.5 to -2, where Rust’s f64::round gives -3), and -0 from -0.5 up to zero, which 1 / Math.round(x) shows.
js_to_fixed
Number.prototype.toFixed(digits): the number rounded to digits places, from its exact binary value. An exact tie rounds away from zero, where Rust’s formatting rounds it to even; at 10²¹ and beyond, JavaScript writes the number as String(x) does.
push_int
String(n) for an integer, which is what toDisplayString and escapeHtml make of a number.
push_number
Number.prototype.toString(): JavaScript’s shortest round-trip digits, laid out as ECMAScript lays them out: 0.30000000000000004, 1e+21, 1.5e-7, NaN, -Infinity.