pub fn load_sources(
    context: &Context,
    options: &Options,
    sources: &mut Sources,
    diagnostics: &mut Diagnostics,
) -> Result<Unit, LoadSourcesError> {
    let visitor = Rc::new(compiling::NoopCompileVisitor::new());
    let source_loader = Rc::new(FileSourceLoader::new());

    load_sources_with_visitor(
        context,
        options,
        sources,
        diagnostics,
        visitor,
        source_loader,
    )
}
/// Load and compile the given sources.
///
/// Uses the [Source::name](runestick::Source::name) when generating diagnostics
/// to reference the file.
///
/// # Examples
///
/// Note: these must be built with the `diagnostics` feature enabled to give
/// access to `rune::termcolor`.
///
/// ```rust
/// use rune::termcolor::{ColorChoice, StandardStream};
/// use rune::EmitDiagnostics as _;
///
/// use std::path::Path;
/// use std::sync::Arc;
/// use std::error::Error;
///
/// # fn main() -> Result<(), Box<dyn Error>> {
/// let context = runestick::Context::with_default_modules()?;
/// let mut options = rune::Options::default();
///
/// let mut sources = rune::Sources::new();
/// sources.insert(runestick::Source::new("entry", r#"
/// pub fn main() {
///     println("Hello World");
/// }
/// "#));
///
/// let mut diagnostics = rune::Diagnostics::new();
///
/// let result = rune::load_sources(&context, &options, &mut sources, &mut diagnostics);
///
/// if !diagnostics.is_empty() {
///     let mut writer = StandardStream::stderr(ColorChoice::Always);
///     diagnostics.emit_diagnostics(&mut writer, &sources)?;
/// }
///
/// let unit = result?;
/// let unit = Arc::new(unit);
/// let vm = runestick::Vm::new(Arc::new(context.runtime()), unit.clone());
/// # Ok(())
/// # }
/// ```
Load and compile the given sources.
Load and compile the given sources .
pub fn load_sources(
    context: &Context,
    options: &Options,
    sources: &mut Sources,
    diagnostics: &mut Diagnostics,
) -> Result<Unit, LoadSourcesError> {
    let visitor = Rc::new(compiling::NoopCompileVisitor::new());
    let source_loader = Rc::new(FileSourceLoader::new());
    load_sources_with_visitor(
        context,
        options,
        sources,
        diagnostics,
        visitor,
        source_loader,
    )
}
pub fn load_sources ( context : & Context , options : & Options , sources : & mut Sources , diagnostics : & mut Diagnostics , ) -> Result < Unit , LoadSourcesError > { let visitor = Rc :: new ( compiling :: NoopCompileVisitor :: new ( ) ) ; let source_loader = Rc :: new ( FileSourceLoader :: new ( ) ) ; load_sources_with_visitor ( context , options , sources , diagnostics , visitor , source_loader , ) }
Load and compile the given sources.
Load and compile the given sources .
context
&Context
options
&Options
sources
&mut Sources
diagnostics
&mut Diagnostics
context
&Context
options
&Options
sources
&mut Sources
diagnostics
&mut Diagnostics
examples
these must be built with the `diagnostics` feature enabled to give
access to `rune::termcolor`.

```rust
use rune::termcolor::{ColorChoice, StandardStream};
use rune::EmitDiagnostics as _.

use std::path::Path;
use std::sync::Arc;
use std::error::Error.
these must be built with the ` diagnostics ` feature enabled to give access to ` rune :: termcolor ` . ` ` ` rust use rune :: termcolor :: { ColorChoice StandardStream } ; use rune :: EmitDiagnostics as _ . use std :: path :: Path ; use std :: sync :: Arc ; use std :: error :: Error .
fn main() -> result<(), box<dyn error>> {
let context = runestick::Context::with_default_modules()?;
let mut options = rune::Options::default().

let mut sources = rune::Sources::new();
sources.insert(runestick::Source::new("entry", r#"
pub fn main() {
println("Hello World");
}
"#)).

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

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

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

let unit = result?;
let unit = Arc::new(unit);
let vm = runestick::Vm::new(Arc::new(context.runtime()), unit.clone()).
let context = runestick :: Context :: with_default_modules () ? ; let mut options = rune :: Options :: default () . let mut sources = rune :: Sources :: new () ; sources . insert ( runestick :: Source :: new ( " entry " r# " pub fn main () { println ( " Hello World " ) ; } " # )) . let mut diagnostics = rune :: Diagnostics :: new () . let result = rune :: load_sources ( &context &options &mut sources &mut diagnostics ) . if !diagnostics . is_empty () { let mut writer = StandardStream :: stderr ( ColorChoice :: Always ) ; diagnostics . emit_diagnostics ( &mut writer &sources ) ? ; } let unit = result? ; let unit = Arc :: new ( unit ) ; let vm = runestick :: Vm :: new ( Arc :: new ( context . runtime () ) unit . clone () ) .
ok(())
None
}
None