Skip to content

Commit

Permalink
Fix examples
Browse files Browse the repository at this point in the history
  • Loading branch information
rscarson committed Jul 10, 2024
1 parent 0a86aa4 commit a29c1aa
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 32 deletions.
2 changes: 1 addition & 1 deletion examples/call_rust_from_js.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ fn main() -> Result<(), Error> {
match runtime.load_module(&module) {
Ok(_) => (),
Err(e) => {
eprintln!("{}", e.as_highlighted());
eprintln!("{}", e.as_highlighted(Default::default()));
}
}

Expand Down
1 change: 0 additions & 1 deletion examples/custom_runtimes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ use std::time::Duration;
// See example_extension for a demonstration
// of creating a deno_core extension for the runtime
mod example_extension;
use example_extension::example_extension;

// A module that will always be loaded into the custom runtime
const MY_MODULE: StaticModule = module!(
Expand Down
1 change: 1 addition & 0 deletions examples/custom_threaded_worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ pub enum MyWorkerMessage {
}

/// The runtime options for our worker
#[derive(Clone)]
pub struct MyWorkerOptions {
pub timeout: std::time::Duration,
}
Expand Down
3 changes: 1 addition & 2 deletions examples/default_threaded_worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,5 @@ fn main() -> Result<(), Error> {
json_args!(1, 2).to_vec(),
)?;
assert_eq!(result, 3);

worker.stop()
Ok(())
}
25 changes: 0 additions & 25 deletions examples/example_extension/example_extension.rs

This file was deleted.

26 changes: 25 additions & 1 deletion examples/example_extension/mod.rs
Original file line number Diff line number Diff line change
@@ -1 +1,25 @@
pub mod example_extension;
///
/// This example shows the definition of a simple extension exposing one op
/// Also see example_extension.js
///
/// Extensions like the one below allow you to let JS code call functions
/// in rust
///
/// Extensions consist of a set of #[op2] functions, an extension! macro,
/// and one or more optional JS modules.
///
///
use rustyscript::deno_core::{extension, op2};

#[op2(fast)]
#[bigint]
fn op_add_example(#[bigint] a: i64, #[bigint] b: i64) -> i64 {
a + b
}

extension!(
example_extension,
ops = [op_add_example],
esm_entry_point = "ext:example_extension/example_extension.js",
esm = [ dir "examples/example_extension", "example_extension.js" ],
);
2 changes: 1 addition & 1 deletion examples/interactive_prompt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ fn interactive_prompt() {
let input = cmd.trim();
match runtime.eval::<ResponseType>(&input) {
Ok(value) => println!("{}\n", value),
Err(e) => eprintln!("{}\n", e.as_highlighted()),
Err(e) => eprintln!("{}\n", e.as_highlighted(Default::default())),
}
}
}
Expand Down
1 change: 0 additions & 1 deletion examples/runtime_extensions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
use rustyscript::{Error, Module, Runtime, RuntimeOptions};

mod example_extension;
use example_extension::example_extension;

fn main() -> Result<(), Error> {
let module = Module::new("test.js", " export const result = example_ext.add(5, 5); ");
Expand Down

0 comments on commit a29c1aa

Please sign in to comment.