Skip to content

Commit cc1b835

Browse files
committed
Add base for testing unions rust.
1 parent 235bc9f commit cc1b835

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

source/scripts/rust/basic/source/basic.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,22 @@ pub fn str_slice(s: &str) -> &str {
6464
&s[0..3]
6565
}
6666
}
67+
68+
// TODO
69+
/*
70+
pub fn age_group(age: i32) -> Result<String, String> {
71+
let valid_age = match age {
72+
_ if age < 0 => return Err("not born yet".to_string()),
73+
_ if age > 150 => return Err("seriously?!!".to_string()),
74+
validated => validated,
75+
};
76+
77+
let result = match valid_age {
78+
_ if age < 10 => "child".to_string(),
79+
_ if age >= 18 => "adult".to_string(),
80+
a => format!("teenager of {} years old", a),
81+
};
82+
83+
Ok(result)
84+
}
85+
*/

source/tests/metacall_rust_test/source/metacall_rust_test.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,18 @@ TEST_F(metacall_rust_test, DefaultConstructor)
154154
metacall_value_destroy(ret);
155155
}
156156

157+
/* TODO */
158+
/*
159+
{
160+
// test if we can return result
161+
void *ret = metacall("age_group", 21);
162+
163+
// TODO
164+
165+
metacall_value_destroy(ret);
166+
}
167+
*/
168+
157169
/* Print inspect information */
158170
{
159171
size_t size = 0;

0 commit comments

Comments
 (0)