Type Definition truck_topology::VertexID
source · Expand description
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.get_point();
let v_id: VertexID<usize> = v.id();
// Change the point!
v.set_point(1);
assert_ne!(entity, v.get_point());
assert_eq!(v_id, v.id());