Skip to main content

KnownSize

Trait KnownSize 

Source
pub trait KnownSize {
    // Required method
    fn size(p: *const Self) -> usize;
}
Expand description

Trait to represent compile-time known size information.

This is a generalization of size_of that works for dynamically sized types.

Required Methods§

Source

fn size(p: *const Self) -> usize

Get the size of an object of this type in bytes, with the metadata of the given pointer.

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.

Implementations on Foreign Types§

Source§

impl<T> KnownSize for [T]

Source§

fn size(p: *const Self) -> usize

Implementors§

Source§

impl<T> KnownSize for T