Skip to main content

HasDefaultViewInstance

Trait HasDefaultViewInstance 

Source
pub unsafe trait HasDefaultViewInstance {
    type Static: DefaultViewInstance;

    // Provided method
    fn default_view_ptr() -> *const u8 { ... }
}
Expand description

Marker trait linking a lifetime-parameterized view type V (e.g., FooView<'a>) to its 'static instantiation that implements DefaultViewInstance. Generated code implements this for every view type.

The default_view_ptr method returns a raw pointer to avoid forcing Self: 'static — view types have a lifetime parameter that may not be 'static, but the default instance only contains 'static data and the types are covariant, so the pointer cast is sound.

§Safety

Self must be layout-identical to Self::Static (i.e., the only difference is the lifetime parameter), and Self must be covariant in that lifetime.

Required Associated Types§

Source

type Static: DefaultViewInstance

The 'static instantiation of this view type.

Provided Methods§

Source

fn default_view_ptr() -> *const u8

Return a pointer to the static default instance, erasing the lifetime so it can be used for any 'a.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§