Skip to main content

ixa/macros/
mod.rs

1mod assert_almost_eq;
2mod define_data_plugin;
3mod define_global_property;
4mod define_report;
5mod define_rng;
6mod edge_impl;
7mod entity_impl;
8mod property_impl;
9mod schedule_relative;
10mod value_change_counts;
11mod with;
12
13/// Writes one plain, newline-terminated message to the user-facing output.
14///
15/// Output is written to stdout on native targets and to `console.log` on Wasm.
16/// Unlike diagnostic logging, it is not affected by logging features, levels,
17/// or module filters.
18///
19/// # Examples
20///
21/// ```
22/// use ixa::output;
23///
24/// output!("simulation complete at time {}", 42.0);
25/// ```
26#[macro_export]
27macro_rules! output {
28    () => {
29        $crate::macros::__output(format_args!(""))
30    };
31    ($($arg:tt)+) => {
32        $crate::macros::__output(format_args!($($arg)*))
33    };
34}
35
36#[doc(hidden)]
37pub fn __output(args: std::fmt::Arguments<'_>) {
38    #[cfg(target_arch = "wasm32")]
39    web_sys::console::log_1(&args.to_string().into());
40
41    #[cfg(not(target_arch = "wasm32"))]
42    println!("{args}");
43}