Skip to content

module

report

Warnings for the developer: a template that did something it probably didn't mean, or a component given the wrong shape of data.

On a native build they go to standard error. In the browser eprintln! goes nowhere, so the runtime installs a sink that sends them to the console (weft_web does this when it mounts an app).

A warning raised while rendering should use warn_once: renders repeat, and the same message on every update is noise.

Functions

reported

pub fn reported() -> Vec<String>

The messages reported so far on this thread, for tests.

set_sink

pub fn set_sink(sink: Sink)

Send warnings to sink instead of standard error.

warn

pub fn warn(message: &str)

Report message, prefixed with weft: .

warn_once

pub fn warn_once(message: &str)

Report message, unless it was reported before.

Type aliases

Sink

pub type Sink = fn(&str);

Where warnings go.