diff --git a/hello/platforms/apple/HelloAppleDemoApp/ViewController.swift b/hello/platforms/apple/HelloAppleDemoApp/ViewController.swift index 7e842bd..b6fe832 100644 --- a/hello/platforms/apple/HelloAppleDemoApp/ViewController.swift +++ b/hello/platforms/apple/HelloAppleDemoApp/ViewController.swift @@ -1,20 +1,18 @@ -// - -import UIKit import Hello +import UIKit class ViewController: UIViewController { - override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view. print(rustGreeting(to: "Bob")) print(Hello.add(a: 1, b: 2)) - + Task { let str = await Hello.sayAfter(ms: 1500, who: "Async") print(str) } + + print(Hello.addObj(a: RustDemoObj(value: 1), b: RustDemoObj(value: 2))) } } - diff --git a/hello/src/lib.rs b/hello/src/lib.rs index da7a742..6325983 100644 --- a/hello/src/lib.rs +++ b/hello/src/lib.rs @@ -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, + } +}