Merge pull request #54 from jhwgh1968/plugins

Add workspace, for both publishing and codegen tests
This commit is contained in:
Stephen Chung 2020-09-09 09:08:23 +08:00 committed by GitHub
commit d127698da9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 85 additions and 1 deletions

View File

@ -52,7 +52,7 @@ jobs:
uses: actions-rs/cargo@v1 uses: actions-rs/cargo@v1
with: with:
command: test command: test
args: --all ${{matrix.flags}} args: ${{matrix.flags}}
# no-std builds are a bit more extensive to test # no-std builds are a bit more extensive to test
no_std_build: no_std_build:
name: NoStdBuild name: NoStdBuild

View File

@ -1,3 +1,9 @@
[workspace]
members = [
".",
"codegen"
]
[package] [package]
name = "rhai" name = "rhai"
version = "0.18.3" version = "0.18.3"

View File

@ -0,0 +1,27 @@
use rhai::plugin::*;
struct NonClonable {
a: f32,
b: u32,
c: char,
d: bool,
}
#[export_fn]
pub fn test_fn(input: f32) -> NonClonable {
NonClonable {
a: input,
b: 10,
c: 'a',
d: true,
}
}
fn main() {
let n = test_fn(20.0);
if n.c == 'a' {
println!("yes");
} else {
println!("no");
}
}

View File

@ -0,0 +1,10 @@
error[E0277]: the trait bound `NonClonable: Clone` is not satisfied
--> $DIR/rhai_fn_non_clonable_return.rs:11:8
|
11 | pub fn test_fn(input: f32) -> NonClonable {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `NonClonable`
|
::: $WORKSPACE/src/any.rs
|
| pub fn from<T: Variant + Clone>(value: T) -> Self {
| ----- required by this bound in `rhai::Dynamic::from`

View File

@ -0,0 +1,29 @@
use rhai::plugin::*;
struct NonClonable {
a: f32,
b: u32,
c: char,
d: bool,
}
#[export_module]
pub mod test_mod {
pub fn test_fn(input: f32) -> NonClonable {
NonClonable {
a: input,
b: 10,
c: 'a',
d: true,
}
}
}
fn main() {
let n = test_mod::test_fn(20.0);
if n.c == 'a' {
println!("yes");
} else {
println!("no");
}
}

View File

@ -0,0 +1,10 @@
error[E0277]: the trait bound `NonClonable: Clone` is not satisfied
--> $DIR/rhai_mod_non_clonable_return.rs:12:12
|
12 | pub fn test_fn(input: f32) -> NonClonable {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `NonClonable`
|
::: $WORKSPACE/src/any.rs
|
| pub fn from<T: Variant + Clone>(value: T) -> Self {
| ----- required by this bound in `rhai::Dynamic::from`

View File

@ -1,5 +1,7 @@
cargo-features = ["named-profiles"] cargo-features = ["named-profiles"]
[workspace]
[package] [package]
name = "no_std_test" name = "no_std_test"
version = "0.1.0" version = "0.1.0"