Type Definition truck_topology::VertexID[][src]

type VertexID<P> = ID<Mutex<P>>;

The id of vertex. Copy trait is implemented.

Details

Since this struct is implemented Copy trait, it is useful to use as a key of hashmaps.

use truck_topology::*;
use std::collections::HashMap;

let v = Vertex::new(0);
let v_id = v.id();

let mut entity_map = HashMap::new();
let mut id_map = HashMap::new();

entity_map.insert(v.clone(), 0); // v must be cloned for sign up the hashmap.
id_map.insert(v_id, 0); // v_id is implemented Copy trait!

The id does not changed even if the value of point changes.

use truck_topology::*;
let v = Vertex::new(0);

let entity = *v.try_lock_point().unwrap();
let v_id: VertexID<usize> = v.id();

// Change the point!
*v.try_lock_point().unwrap() = 1;

assert_ne!(entity, *v.try_lock_point().unwrap());
assert_eq!(v_id, v.id());