Struct tskit::NodeId [−][src]
#[repr(transparent)]pub struct NodeId(_);
Expand description
A node ID
This is an integer referring to a row of a NodeTable
.
The underlying type is tsk_id_t
.
Examples
These examples illustrate using this type as something “integer-like”.
use tskit::NodeId;
use tskit::tsk_id_t;
let x: tsk_id_t = 1;
let y: NodeId = NodeId::from(x);
assert_eq!(x, y);
assert_eq!(y, x);
assert!(y < x + 1);
assert!(y <= x);
assert!(x + 1 > y);
assert!(x + 1 >= y);
let z: NodeId = NodeId::from(x);
assert_eq!(y, z);
It is also possible to write functions accepting both the NodeId
and tsk_id_t
:
use tskit::NodeId;
use tskit::tsk_id_t;
fn interesting<N: Into<NodeId>>(x: N) -> NodeId {
x.into()
}
let x: tsk_id_t = 0;
assert_eq!(interesting(x), x);
let x: NodeId = NodeId::from(0);
assert_eq!(interesting(x), x);
The types also implement Display
:
use tskit::NodeId;
let n = NodeId::from(11);
assert_eq!(format!("{}", n), "NodeId(11)".to_string());
let n = NodeId::from(NodeId::NULL);
assert_eq!(format!("{}", n), "NodeId(NULL)".to_string());
Implementations
Trait Implementations
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
Auto Trait Implementations
impl RefUnwindSafe for NodeId
impl UnwindSafe for NodeId
Blanket Implementations
Mutably borrows from an owned value. Read more