#[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::bindings::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::bindings::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
sourceimpl Ord for NodeId
impl Ord for NodeId
sourceimpl PartialOrd<NodeId> for NodeId
impl PartialOrd<NodeId> for NodeId
sourcefn partial_cmp(&self, other: &NodeId) -> Option<Ordering>
fn partial_cmp(&self, other: &NodeId) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
sourceimpl PartialOrd<NodeId> for tsk_id_t
impl PartialOrd<NodeId> for tsk_id_t
sourcefn partial_cmp(&self, other: &NodeId) -> Option<Ordering>
fn partial_cmp(&self, other: &NodeId) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
sourceimpl PartialOrd<NodeId> for SizeType
impl PartialOrd<NodeId> for SizeType
sourcefn partial_cmp(&self, other: &NodeId) -> Option<Ordering>
fn partial_cmp(&self, other: &NodeId) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
sourceimpl PartialOrd<SizeType> for NodeId
impl PartialOrd<SizeType> for NodeId
sourcefn partial_cmp(&self, other: &SizeType) -> Option<Ordering>
fn partial_cmp(&self, other: &SizeType) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
sourceimpl PartialOrd<i32> for NodeId
impl PartialOrd<i32> for NodeId
sourcefn partial_cmp(&self, other: &tsk_id_t) -> Option<Ordering>
fn partial_cmp(&self, other: &tsk_id_t) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
impl Copy for NodeId
impl Eq for NodeId
impl StructuralEq for NodeId
impl StructuralPartialEq for NodeId
Auto Trait Implementations
impl RefUnwindSafe for NodeId
impl Send for NodeId
impl Sync for NodeId
impl Unpin for NodeId
impl UnwindSafe for NodeId
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more