runestick 0.6.8

Runescript, a generic stack-based virtual machine for Rust.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
//! The `std::fmt` module.

use crate::{ContextError, Module};
use std::fmt;
use std::fmt::Write as _;

/// Construct the `std::fmt` module.
pub fn module() -> Result<Module, ContextError> {
    let mut module = Module::new(&["std", "fmt"]);
    module.ty(&["Error"]).build::<std::fmt::Error>()?;
    module.inst_fn(crate::STRING_DISPLAY, format_fmt_error)?;
    Ok(module)
}

fn format_fmt_error(error: &std::fmt::Error, buf: &mut String) -> fmt::Result {
    write!(buf, "{}", error)
}