Skip to main content

Width

Trait Width 

Source
pub trait Width: Sealed {
    type Pointer: Pointer;
}
Expand description

A pointer width that can be used to reference other nodes.

This is determined by a primitive unsigned types such as u32 or usize.

Required Associated Types§

Source

type Pointer: Pointer

The pointer type associated with a specific width.

§Examples
use syntree::pointer::Width;

let tree = syntree::tree! {
    "root1" => {},
    "root2" => {},
};

let root1 = tree.first().and_then(|n| n.into_node()).ok_or("missing root")?;
let root2 = tree.last().and_then(|n| n.into_node()).ok_or("missing root")?;

let root1: <u32 as Width>::Pointer = root1.id();
let root2: <u32 as Width>::Pointer = root2.id();

assert_ne!(root1, root2);

Dyn Compatibility§

This trait is dyn compatible.

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

Implementations on Foreign Types§

Source§

impl Width for u8

Source§

impl Width for u16

Source§

impl Width for u32

Source§

impl Width for u64

Source§

impl Width for u128

Source§

impl Width for usize

Implementors§