Skip to main content

LinkReference

Trait LinkReference 

Source
pub trait LinkReference:
    Number
    + Unsigned
    + ToSigned
    + MaxValue
    + FromPrimitive
    + Debug
    + Display
    + Hash
    + Send
    + Sync
    + 'static { }
Expand description

A composite trait for types that can be used as link identifiers.

Combines Number, Unsigned, ToSigned, MaxValue, FromPrimitive, Debug, Display, Hash, Send, Sync, and 'static.

Implemented for u8, u16, u32, u64, and usize.

§Design note

Supertraits are listed explicitly rather than via type aliases, because some IDEs do not fully resolve trait aliases for autocompletion and go-to-definition.

§Examples

use platform_num::LinkReference;

fn create_link<T: LinkReference>(source: T, target: T) -> (T, T) {
    (source, target)
}

let link = create_link(1u64, 2u64);
assert_eq!(link, (1u64, 2u64));

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§