Skip to main content

DWordExt

Trait DWordExt 

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

    // Provided methods
    fn loword(self) -> u16 { ... }
    fn hiword(self) -> u16 { ... }
    fn split(self) -> (u16, u16) { ... }
}
Expand description

This trait provides the freestanding functions from minwindef directly on DWORDs (u32).

When using new-types that wrap a DWORD, 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::DWordExt; // or: windows_ext::minwindef::ext::DWordExt;

assert_eq!(0x1234_5678u32.hiword(), 0x1234);
assert_eq!(0x1234_5678u32.loword(), 0x5678);

Required Methods§

Source

fn value(self) -> u32

Gets the value of the DWORD.

Provided Methods§

Source

fn loword(self) -> u16

Get the low order word as u16

assert_eq!(0x1234_5678u32.loword(), 0x5678);
Source

fn hiword(self) -> u16

Get the high order word as u16

assert_eq!(0x1234_5678u32.hiword(), 0x1234);
Source

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

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

assert_eq!(0x1234_5678u32.split(), (0x5678, 0x1234));

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementations on Foreign Types§

Source§

impl DWordExt for u32

Source§

fn value(self) -> u32

Source§

impl DWordExt for usize

Source§

fn value(self) -> u32

DWord value of a usize. On 64-bit this truncates to the lower 32.

Implementors§