Wedson Almeida Filho <wedsonaf@xxxxxxxxx> writes: [...] > +// SAFETY: The type invariants guarantee that `INode` is always ref-counted. > +unsafe impl AlwaysRefCounted for Head { > + fn inc_ref(&self) { > + // SAFETY: The existence of a shared reference means that the refcount is nonzero. > + unsafe { bindings::get_bh(self.0.get()) }; > + } > + > + unsafe fn dec_ref(obj: ptr::NonNull<Self>) { > + // SAFETY: The safety requirements guarantee that the refcount is nonzero. > + unsafe { bindings::put_bh(obj.cast().as_ptr()) } I would prefer the target type of the cast to be explicit. > + } > +} > + > +impl Head { > + /// Returns the block data associated with the given buffer head. > + pub fn data(&self) -> &[u8] { > + let h = self.0.get(); > + // SAFETY: The existence of a shared reference guarantees that the buffer head is > + // available and so we can access its contents. > + unsafe { core::slice::from_raw_parts((*h).b_data.cast(), (*h).b_size) } Same BR Andreas