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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
use ;
/// A wrapper type that makes a registered type safe to pass to and from Roto.
///
/// Only types that implement the sealed [`Value`] trait can be passed to
/// Roto. Some primitive types implement this trait directly, but every other
/// type needs to be wrapped in [`Val`]. You should not wrap the primitives in
/// [`Val`].
///
/// This type implements [`Deref`] and [`DerefMut`] to allow for easy access to
/// the inner value.
///
/// ```rust,ignore
/// #[derive(Clone)]
/// struct Foo {
/// a: i32,
/// b: i32,
/// }
///
/// let rt = Runtime::from_lib(library! {
/// #[clone] type Foo = Val<Foo>;
/// }).unwrap();
///
/// // compile a script...
///
/// // Pass Foo to Roto wrapped in Val:
/// let f = pkg.get_function::<fn(Val<Foo>) -> ()>("main").unwrap();
/// f.call(Val(Foo { a: 1, b: 2 }));
///
/// // For Option and Verdict, wrap the inner type in Val
/// pkg.get_function::<fn(Option<Val<Foo>>) -> ()>("main").unwrap();
///
/// // Do not wrap types that already implement Value.
/// pkg.get_function::<fn(i32) -> ()>("main").unwrap();
/// ```
///
/// [`Value`]: super::Value
;