Skip to main content

Id

Trait Id 

Source
pub trait Id:
    Copy
    + Eq
    + Hash
    + Ord
    + Send
    + Sync
    + Sized
    + 'static {
    // Required methods
    fn from_u32(value: u32) -> Self;
    fn id(&self) -> u32;
}
Expand description

The ids component storages are indexed with. This is mostly just a newtype wrapper with a u32 in it.

§Examples

use specs_static::Id;

#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct MyAmazingId(pub u32);

impl Id for MyAmazingId {
    fn from_u32(value: u32) -> Self {
        MyAmazingId(value)
    }

    fn id(&self) -> u32 {
        self.0
    }
}

Required Methods§

Source

fn from_u32(value: u32) -> Self

Creates an idea from a u32.

Source

fn id(&self) -> u32

Returns the id integer value.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§