I'm trying to implement a mesh data structure in Rust, and I'm having trouble working out how to use lifetimes correctly. What I want is for the mesh to contain vertices, edges holding references to vertices, triangles holding references to edges, and tetrahedra holding references to triangles. The part where I am having trouble is that if a vertex is deleted, everything that contains it should be deleted. But the vertices all have different lifetimes, and I don't see any way to include that information in my struct definition. How can I get the behavior that I want?
struct Mesh<'vertex: 'edge, 'edge: 'triangle, 'triangle, T>
{
vertices: std::vec::Vec<Vertex<T>>,
edges: std::vec::Vec<Edge<'vertex, T>>,
triangles: std::vec::Vec<Triangle<'vertex, 'edge, T>>,
tetrahedra: std::vec::Vec<Tetrahedron<'vertex, 'edge, 'triangle, T>>,
}