MCPcopy Create free account
hub / github.com/RustCV/RustCV / new

Method new

rustcv-backend-avf/src/delegate.rs:163–170  ·  view source on GitHub ↗

创建新的 Delegate 实例并绑定 Sender。 # objc2 0.6 IVar 初始化正确模式 ```text Self::alloc() → 分配内存(Allocated ,ivar 为 MaybeUninit) .set_ivars(value) → 写入初始值(将 MaybeUninit 标记为已初始化) → msg_send![super(this), init] → 调用父类 init,返回 Retained ``` 这是 objc2 0.6 文档中唯一正确的带 ivar 初始化的对象构造方式。 不能使用 `msg_send![Self::class(), new]`,因为 `new` = alloc+init 但 绕过了 `set_ivars`,导致 self.ivars() 访问 MaybeUninit 而

(sender: Sender<AvfFrameData>)

Source from the content-addressed store, hash-verified

161 /// 不能使用 `msg_send![Self::class(), new]`,因为 `new` = alloc+init 但
162 /// 绕过了 `set_ivars`,导致 self.ivars() 访问 MaybeUninit 而 panic。
163 pub fn new(sender: Sender<AvfFrameData>) -> Retained<Self> {
164 // Step 1: 分配内存并写入 ivar 初始值
165 let this: Allocated<Self> = Self::alloc();
166 let this = this.set_ivars(DelegateIvars { sender });
167
168 // Step 2: 调用父类(NSObject)的 init,转换为完整的 Retained<Self>
169 unsafe { msg_send![super(this), init] }
170 }
171}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected