File: second_shared_ref.rs

package info (click to toggle)
rust-rhai-codegen 2.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 888 kB
  • sloc: makefile: 2
file content (29 lines) | stat: -rw-r--r-- 462 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#![allow(deprecated)]
use rhai::plugin::*;

#[derive(Clone)]
pub struct Clonable {
    a: f32,
    b: u32,
    c: char,
    d: bool,
}

#[export_fn]
pub fn test_fn(input: Clonable, factor: &bool) -> bool {
    input.d & factor
}

fn main() {
    let n = Clonable {
        a: 0.0,
        b: 10,
        c: 'a',
        d: true,
    };
    if test_fn(n, &true) {
        println!("yes");
    } else {
        println!("no");
    }
}