> +unsafe extern "C" fn rust_instance_init<T: ObjectImpl>(obj: *mut Object) {
> + // SAFETY: obj is an instance of T, since rust_instance_init<T>
> + // is called from QOM core as the instance_init function
> + // for class T
> + unsafe { T::INSTANCE_INIT.unwrap()(&mut *obj.cast::<T>()) }
> +}
Here's the difference, why doesn't init() narrow the unsafe scope like
post_init() does?
> +unsafe extern "C" fn rust_instance_post_init<T: ObjectImpl>(obj: *mut
> Object) {
> + // SAFETY: obj is an instance of T, since rust_instance_post_init<T>
> + // is called from QOM core as the instance_post_init function
> + // for class T
> + //
> + // FIXME: it's not really guaranteed that there are no backpointers to
> + // obj; it's quite possible that they have been created by
> instance_init().
> + // The receiver should be &self, not &mut self.
> + T::INSTANCE_POST_INIT.unwrap()(unsafe { &mut *obj.cast::<T>() })
> +}
> +