Skip to content

Commit dab3be4

Browse files
committed
Handle newer versions of Rhai in build.
1 parent 5193cb6 commit dab3be4

File tree

2 files changed

+21
-15
lines changed

2 files changed

+21
-15
lines changed

Cargo.toml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rhai-sci"
3-
version = "0.2.0"
3+
version = "0.2.1"
44
edition = "2021"
55
authors = ["Chris McComb <[email protected]>"]
66
description = "Scientific computing in the Rhai scripting language"
@@ -22,23 +22,23 @@ rand = ["randlib"]
2222

2323
[dependencies]
2424
rhai = ">=1.8.0"
25-
nalgebralib = {version = "0.32.1", optional = true, package = "nalgebra" }
26-
polars = {version = "0.27.2", optional = true }
27-
url = {version = "2.2.2", optional = true }
28-
temp-file = {version = "0.1.6", optional = true }
29-
csv-sniffer = {version = "0.3.1", optional = true }
25+
nalgebralib = { version = "0.32.1", optional = true, package = "nalgebra" }
26+
polars = { version = "0.27.2", optional = true }
27+
url = { version = "2.2.2", optional = true }
28+
temp-file = { version = "0.1.6", optional = true }
29+
csv-sniffer = { version = "0.3.1", optional = true }
3030
minreq = { version = "2.6.0", features = ["json-using-serde", "https"], optional = true }
3131
randlib = { version = "0.8", optional = true, package = "rand" }
3232
smartstring = "1.0.1"
3333
linregress = { version = "0.5.0", optional = true }
3434

3535
[build-dependencies]
3636
rhai = ">=1.8.0"
37-
nalgebralib = {version = "0.32.1", optional = true, package = "nalgebra" }
38-
polars = {version = "0.27.2", optional = true }
39-
url = {version = "2.2.2", optional = true }
40-
temp-file = {version = "0.1.6", optional = true }
41-
csv-sniffer = {version = "0.3.1", optional = true }
37+
nalgebralib = { version = "0.32.1", optional = true, package = "nalgebra" }
38+
polars = { version = "0.27.2", optional = true }
39+
url = { version = "2.2.2", optional = true }
40+
temp-file = { version = "0.1.6", optional = true }
41+
csv-sniffer = { version = "0.3.1", optional = true }
4242
minreq = { version = "2.6.0", features = ["json-using-serde", "https"], optional = true }
4343
randlib = { version = "0.8", optional = true, package = "rand" }
4444
serde_json = "1.0.82"

build.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ fn main() {
1616
use std::collections::HashMap;
1717
use std::io::Write;
1818

19+
#[derive(Serialize, Deserialize, Debug, Clone)]
20+
struct Metadata {
21+
#[serde(default)]
22+
pub functions: Vec<Function>,
23+
}
1924
#[allow(non_snake_case)]
2025
#[derive(Serialize, Deserialize, Debug, Clone)]
2126
struct Function {
@@ -40,7 +45,8 @@ fn main() {
4045
std::fs::File::create(std::env::var("OUT_DIR").unwrap() + "/rhai-sci-docs.md").unwrap();
4146

4247
// Make a file for tests
43-
let mut test_file = std::fs::File::create(std::env::var("OUT_DIR").unwrap() + "/rhai-sci-tests.rs").unwrap();
48+
let mut test_file =
49+
std::fs::File::create(std::env::var("OUT_DIR").unwrap() + "/rhai-sci-tests.rs").unwrap();
4450

4551
// Build an engine for doctests
4652
let mut engine = Engine::new();
@@ -62,12 +68,12 @@ fn main() {
6268
// Extract metadata
6369
let json_fns = engine.gen_fn_metadata_to_json(false).unwrap();
6470
println!("{json_fns}");
65-
let v: HashMap<String, Vec<Function>> = serde_json::from_str(&json_fns).unwrap();
66-
for function in v["functions"].clone() {
71+
let v: Metadata = serde_json::from_str(&json_fns).unwrap();
72+
for function in v.functions {
6773
println!("{:?}", function);
6874
}
6975

70-
let function_list = v["functions"].clone();
76+
let function_list = v.functions;
7177

7278
// Write functions
7379
write!(doc_file, "\n# API\n This package provides a large variety of functions to help with scientific computing:\n").expect("Cannot write to {doc_file}");

0 commit comments

Comments
 (0)