wac-parser 0.10.0

A library for parsing and encoding WebAssembly Composition (WAC) source files.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use miette::{GraphicalReportHandler, GraphicalTheme, NamedSource, Report};
use std::path::Path;

pub fn fmt_err(e: impl Into<Report>, path: &Path, source: &str) -> String {
    let mut s = String::new();
    let e = e.into();
    GraphicalReportHandler::new()
        .with_cause_chain()
        .with_theme(GraphicalTheme::unicode_nocolor())
        .render_report(
            &mut s,
            e.with_source_code(NamedSource::new(path.to_string_lossy(), source.to_string()))
                .as_ref(),
        )
        .expect("failed to render diagnostic");
    s
}