pub fn build(
    context: &runestick::Context,
    source: &str,
) -> runestick::Result<Arc<runestick::Unit>> {
    let options = Options::default();
    let mut sources = Sources::new();
    sources.insert(Source::new("source", source));

    let mut diagnostics = rune::Diagnostics::new();

    let result = rune::load_sources(&*context, &options, &mut sources, &mut diagnostics);

    if !diagnostics.is_empty() {
        let mut writer =
            rune::termcolor::StandardStream::stderr(rune::termcolor::ColorChoice::Always);
        rune::EmitDiagnostics::emit_diagnostics(&diagnostics, &mut writer, &sources)?;
    }

    Ok(std::sync::Arc::new(result?))
}
/// Helper function to construct a context and unit from a Rune source for
/// testing purposes.
///
/// This is primarily used in examples.
Helper function to construct a context and unit from a Rune source for
testing purposes.

This is primarily used in examples.
Helper function to construct a context and unit from a Rune source for testing purposes . This is primarily used in examples .
pub fn build(
    context: &runestick::Context,
    source: &str,
) -> runestick::Result<Arc<runestick::Unit>> {
    let options = Options::default();
    let mut sources = Sources::new();
    sources.insert(Source::new("source", source));
    let mut diagnostics = rune::Diagnostics::new();
    let result = rune::load_sources(&*context, &options, &mut sources, &mut diagnostics);
    if !diagnostics.is_empty() {
        let mut writer =
            rune::termcolor::StandardStream::stderr(rune::termcolor::ColorChoice::Always);
        rune::EmitDiagnostics::emit_diagnostics(&diagnostics, &mut writer, &sources)?;
    }
    Ok(std::sync::Arc::new(result?))
}
pub fn build ( context : & runestick :: Context , source : & str , ) -> runestick :: Result < Arc < runestick :: Unit > > { let options = Options :: default ( ) ; let mut sources = Sources :: new ( ) ; sources . insert ( Source :: new ( " " , source ) ) ; let mut diagnostics = rune :: Diagnostics :: new ( ) ; let result = rune :: load_sources ( & * context , & options , & mut sources , & mut diagnostics ) ; if ! diagnostics . is_empty ( ) { let mut writer = rune :: termcolor :: StandardStream :: stderr ( rune :: termcolor :: ColorChoice :: Always ) ; rune :: EmitDiagnostics :: emit_diagnostics ( & diagnostics , & mut writer , & sources ) ? ; } Ok ( std :: sync :: Arc :: new ( result ? ) ) }
Helper function to construct a context and unit from a Rune source for
testing purposes.
Helper function to construct a context and unit from a Rune source for testing purposes .
context
&runestick::Context
source
&str
context
&runestick::Context
source
&str