Trait ConstInit

Source
pub trait ConstInit {
    const INIT: Self;
}
Expand description

A simple trait that can be used as a bound for “can be const created”.

Think of it like the Default trait, but for const values.

Useful for cases where you want a const fn new() -> Self, but only for a subset of types that can be statically created, such as inline buffers vs heap allocated buffers.

I got tired of writing this in multiple crates, so now it’s its own crate.

Required Associated Constants§

Source

const INIT: Self

The default value of this type

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§