Skip to main content

LinkReference

Trait LinkReference 

Source
pub trait LinkReference:
    Sized
    + Number
    + Unsigned
    + ToSigned
    + MaxValue
    + WrappingArithmetic
    + FromPrimitive
    + TryFrom<i8>
    + TryFrom<u8>
    + TryFrom<i16>
    + TryFrom<u16>
    + TryFrom<i32>
    + TryFrom<u32>
    + TryFrom<i64>
    + TryFrom<u64>
    + TryFrom<i128>
    + TryFrom<u128>
    + TryFrom<isize>
    + TryFrom<usize>
    + TryInto<i8>
    + TryInto<u8>
    + TryInto<i16>
    + TryInto<u16>
    + TryInto<i32>
    + TryInto<u32>
    + TryInto<i64>
    + TryInto<u64>
    + TryInto<i128>
    + TryInto<u128>
    + TryInto<isize>
    + TryInto<usize>
    + Debug
    + Display
    + Hash
    + Send
    + Sync
    + 'static
where Self::Error: Debug, Self::Error: Debug, Self::Error: Debug, Self::Error: Debug, Self::Error: Debug, Self::Error: Debug, Self::Error: Debug, Self::Error: Debug, Self::Error: Debug, Self::Error: Debug, Self::Error: Debug, Self::Error: Debug, Self::Error: Debug, Self::Error: Debug, Self::Error: Debug, Self::Error: Debug, Self::Error: Debug, Self::Error: Debug, Self::Error: Debug, Self::Error: Debug, Self::Error: Debug, Self::Error: Debug, Self::Error: Debug, Self::Error: Debug,
{ // Provided method fn from_byte(n: u8) -> Self { ... } }
Expand description

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

Combines Number, Unsigned, ToSigned, MaxValue, WrappingArithmetic, FromPrimitive, TryFrom/TryInto for all integer types, Debug, Display, Hash, Send, Sync, and 'static.

Implemented for u8, u16, u32, u64, u128, 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));

Provided Methods§

Source

fn from_byte(n: u8) -> Self

Creates a value of this type from a u8, panicking on overflow.

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§

Source§

impl<All> LinkReference for All
where All: Number + Unsigned + ToSigned + MaxValue + WrappingArithmetic + FromPrimitive + TryFrom<i8> + TryFrom<u8> + TryFrom<i16> + TryFrom<u16> + TryFrom<i32> + TryFrom<u32> + TryFrom<i64> + TryFrom<u64> + TryFrom<i128> + TryFrom<u128> + TryFrom<isize> + TryFrom<usize> + TryInto<i8> + TryInto<u8> + TryInto<i16> + TryInto<u16> + TryInto<i32> + TryInto<u32> + TryInto<i64> + TryInto<u64> + TryInto<i128> + TryInto<u128> + TryInto<isize> + TryInto<usize> + Debug + Display + Hash + Send + Sync + 'static, <All as TryFrom<i8>>::Error: Debug, <All as TryFrom<u8>>::Error: Debug, <All as TryFrom<i16>>::Error: Debug, <All as TryFrom<u16>>::Error: Debug, <All as TryFrom<i32>>::Error: Debug, <All as TryFrom<u32>>::Error: Debug, <All as TryFrom<i64>>::Error: Debug, <All as TryFrom<u64>>::Error: Debug, <All as TryFrom<i128>>::Error: Debug, <All as TryFrom<u128>>::Error: Debug, <All as TryFrom<isize>>::Error: Debug, <All as TryFrom<usize>>::Error: Debug, <All as TryInto<i8>>::Error: Debug, <All as TryInto<u8>>::Error: Debug, <All as TryInto<i16>>::Error: Debug, <All as TryInto<u16>>::Error: Debug, <All as TryInto<i32>>::Error: Debug, <All as TryInto<u32>>::Error: Debug, <All as TryInto<i64>>::Error: Debug, <All as TryInto<u64>>::Error: Debug, <All as TryInto<i128>>::Error: Debug, <All as TryInto<u128>>::Error: Debug, <All as TryInto<isize>>::Error: Debug, <All as TryInto<usize>>::Error: Debug,