Skip to content

Commit 34f52eb

Browse files
authored
Merge pull request #216 from madsmtm/support-unsafe-fn
Support `unsafe fn` in `declare_class!` macro
2 parents db8a236 + d2b6496 commit 34f52eb

File tree

3 files changed

+324
-328
lines changed

3 files changed

+324
-328
lines changed

objc2-foundation/examples/declaration.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,12 @@ declare_class! {
4949
//
5050
// TODO: Investigate this!
5151
unsafe impl {
52+
/// This is `unsafe` because it expects `sender` to be valid
5253
#[sel(applicationDidFinishLaunching:)]
53-
fn did_finish_launching(&self, _sender: *mut Object) {
54+
unsafe fn did_finish_launching(&self, sender: *mut Object) {
5455
println!("Did finish launching!");
56+
// Do something with `sender`
57+
dbg!(sender);
5558
}
5659

5760
/// Some comment before `sel`.

0 commit comments

Comments
 (0)