pub fn run_with_diagnostics<N, A, T>(
    context: &Arc<runestick::Context>,
    source: &str,
    function: N,
    args: A,
) -> Result<T, RunError>
where
    N: IntoIterator,
    N::Item: IntoComponent,
    A: runestick::Args,
    T: runestick::FromValue,
{
    use rune::EmitDiagnostics as _;

    let mut sources = Sources::new();
    sources.insert(Source::new("main", source.to_owned()));

    let e = match internal_run(context, &mut sources, function, args) {
        Ok(value) => return Ok(value),
        Err(e) => e,
    };

    let mut writer = rune::termcolor::StandardStream::stdout(rune::termcolor::ColorChoice::Never);

    match &e {
        RunError::Diagnostics(diagnostics) => {
            diagnostics
                .emit_diagnostics(&mut writer, &sources)
                .expect("emit diagnostics");
        }
        RunError::VmError(e) => {
            e.emit_diagnostics(&mut writer, &sources)
                .expect("emit diagnostics");
        }
    }

    Err(e)
}
/// Run the given source with diagnostics being printed to stderr.
Run the given source with diagnostics being printed to stderr.
Run the given source with diagnostics being printed to stderr .
pub fn run_with_diagnostics<N, A, T>(
    context: &Arc<runestick::Context>,
    source: &str,
    function: N,
    args: A,
) -> Result<T, RunError>
where
    N: IntoIterator,
    N::Item: IntoComponent,
    A: runestick::Args,
    T: runestick::FromValue,
{
    use rune::EmitDiagnostics as _;
    let mut sources = Sources::new();
    sources.insert(Source::new("main", source.to_owned()));
    let e = match internal_run(context, &mut sources, function, args) {
        Ok(value) => return Ok(value),
        Err(e) => e,
    };
    let mut writer = rune::termcolor::StandardStream::stdout(rune::termcolor::ColorChoice::Never);
    match &e {
        RunError::Diagnostics(diagnostics) => {
            diagnostics
                .emit_diagnostics(&mut writer, &sources)
                .expect("emit diagnostics");
        }
        RunError::VmError(e) => {
            e.emit_diagnostics(&mut writer, &sources)
                .expect("emit diagnostics");
        }
    }
    Err(e)
}
pub fn run_with_diagnostics < N , A , T > ( context : & Arc < runestick :: Context > , source : & str , function : N , args : A , ) -> Result < T , RunError > where N : IntoIterator , N :: Item : IntoComponent , A : runestick :: Args , T : runestick :: FromValue , { use rune :: EmitDiagnostics as _ ; let mut sources = Sources :: new ( ) ; sources . insert ( Source :: new ( " " , source . to_owned ( ) ) ) ; let e = match internal_run ( context , & mut sources , function , args ) { Ok ( value ) => return Ok ( value ) , Err ( e ) => e , } ; let mut writer = rune :: termcolor :: StandardStream :: stdout ( rune :: termcolor :: ColorChoice :: Never ) ; match & e { RunError :: Diagnostics ( diagnostics ) => { diagnostics . emit_diagnostics ( & mut writer , & sources ) . expect ( " " ) ; } RunError :: VmError ( e ) => { e . emit_diagnostics ( & mut writer , & sources ) . expect ( " " ) ; } } Err ( e ) }
Run the given source with diagnostics being printed to stderr.
Run the given source with diagnostics being printed to stderr .
context
&Arc<runestick::Context>
source
&str
function
N
args
A
context
&Arc<runestick::Context>
source
&str
function
N
args
A