A value-to-value conversion that consumes the input value.
Note: This trait must not fail. If the conversion can fail, use TryInto.
Signature
pub trait Into
Generic Implementations
Into is reflexive, which means that Into is implemented
Examples
Converting from RGB components to a packed color value:
#[derive(Copy, Drop, PartialEq)]struct Color { // Packed as 0x00RRGGBB value: u32,}impl RGBIntoColor of Into { fn into(self: (u8, u8, u8)) -> Color { let (r, g, b) = self; let value = (r.into() * 0x10000_u32) + (g.into() * 0x100_u32) + b.into(); Color { value } }}// Convert RGB(255, 128, 0) to 0x00FF8000let orange: Color = (255_u8, 128_u8, 0_u8).into();assert!(orange == Color { value: 0x00FF8000_u32 });