Skip to main content

ObjectCoreWithExtraItems

Trait ObjectCoreWithExtraItems 

Source
pub unsafe trait ObjectCoreWithExtraItems: ObjectCore {
    type ExtraItem;

    // Required method
    fn extra_items_count(this: &Self) -> usize;

    // Provided methods
    unsafe fn extra_items_ptr(this: *mut Self) -> *mut Self::ExtraItem { ... }
    unsafe fn extra_items<'a>(this: *const Self) -> &'a [Self::ExtraItem] { ... }
}
Expand description

An object type whose allocation is followed by a run of extra items, such as the dimensions of a Shape.

The items lie past Self, so a pointer to them is derived from a pointer to the whole allocation, such as ObjectArc::as_ptr, never from a &Self, which covers Self only.

§Safety

Every allocation of Self is followed by extra_items_count ExtraItems, as ObjectArc::new_with_extra_items lays them out. The count stays the same for the object’s life, and the items are never dropped.

Required Associated Types§

Source

type ExtraItem

The type of the items that follow the object.

Required Methods§

Source

fn extra_items_count(this: &Self) -> usize

The number of extra items.

Provided Methods§

Source

unsafe fn extra_items_ptr(this: *mut Self) -> *mut Self::ExtraItem

A pointer to the first extra item.

§Safety

this points to an allocation that carries its extra items, and its provenance covers them.

Source

unsafe fn extra_items<'a>(this: *const Self) -> &'a [Self::ExtraItem]

The extra items.

§Safety

As extra_items_ptr, with the items initialized and not written for 'a.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§