use record exported types

This commit is contained in:
imWildCat 2023-10-21 06:16:07 -04:00
parent 25e6752583
commit 74b0cab9b5
2 changed files with 16 additions and 6 deletions

View File

@ -1,10 +1,7 @@
//
import UIKit
import Hello
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
@ -15,6 +12,7 @@ class ViewController: UIViewController {
let str = await Hello.sayAfter(ms: 1500, who: "Async")
print(str)
}
}
}
print(Hello.addObj(a: RustDemoObj(value: 1), b: RustDemoObj(value: 2)))
}
}

View File

@ -57,3 +57,15 @@ pub async fn say_after(ms: u64, who: String) -> String {
.unwrap_err();
format!("Hello, {who}!")
}
#[derive(uniffi::Record)]
pub struct RustDemoObj {
pub value: i64,
}
#[uniffi::export]
pub fn add_obj(a: &RustDemoObj, b: &RustDemoObj) -> RustDemoObj {
RustDemoObj {
value: a.value + b.value,
}
}