use record exported types
This commit is contained in:
parent
25e6752583
commit
74b0cab9b5
|
@ -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)))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue