WordExt

Trait WordExt 

Source
pub trait WordExt: Copy {
    // Required method
    fn value(self) -> u16;

    // Provided methods
    fn lobyte(self) -> u8 { ... }
    fn hibyte(self) -> u8 { ... }
    fn split(self) -> (u8, u8) { ... }
}
Expand description

This trait provides the freestanding functions from minwindef directly on WORDs (u16).

When using new-types that wrap a WORD, you can implement this trait by implementing the value method.

This trait is included in the convenience wrapper windows_ext::ext.

use windows_ext::ext::WordExt; // or: windows_ext::minwindef::ext::DWordExt;

assert_eq!(0x12_34u16.hibyte(), 0x12);
assert_eq!(0x12_34u16.lobyte(), 0x34);

Required Methods§

Source

fn value(self) -> u16

Provide the value of the WORD

Provided Methods§

Source

fn lobyte(self) -> u8

Get the low order word as u16

assert_eq!(0x12_34u16.lobyte(), 0x34);
Source

fn hibyte(self) -> u8

Get the high order word as u16

assert_eq!(0x12_34u16.hibyte(), 0x12);
Source

fn split(self) -> (u8, u8)

Split a single dword into both of its words (lo, hi)

assert_eq!(0x12_34u16.split(), (0x34, 0x12));

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 WordExt for u16

Source§

fn value(self) -> u16

Implementors§