pub trait GraphMut<V, E>: GraphRef<V, E> {
// Required methods
fn vertex_mut(&mut self, id: &Self::VertexId) -> Option<&mut V>;
fn edge_mut(&mut self, id: &Self::EdgeId) -> Option<&mut E>;
// Provided methods
fn try_replace_vertex(
&mut self,
id: &Self::VertexId,
vertex: V,
) -> Result<V, ReplaceVertexError<V>> { ... }
fn replace_vertex(&mut self, id: &Self::VertexId, vertex: V) -> V { ... }
fn try_replace_edge(
&mut self,
id: &Self::EdgeId,
edge: E,
) -> Result<E, ReplaceEdgeError<E>> { ... }
fn replace_edge(&mut self, id: &Self::EdgeId, edge: E) -> E { ... }
}Expand description
Trait for mutable access to graph attributes.
§Implementation notes
Required Methods§
Sourcefn vertex_mut(&mut self, id: &Self::VertexId) -> Option<&mut V>
fn vertex_mut(&mut self, id: &Self::VertexId) -> Option<&mut V>
Returns a mutable reference to the vertex attribute, if it exists.
Provided Methods§
Sourcefn try_replace_vertex(
&mut self,
id: &Self::VertexId,
vertex: V,
) -> Result<V, ReplaceVertexError<V>>
fn try_replace_vertex( &mut self, id: &Self::VertexId, vertex: V, ) -> Result<V, ReplaceVertexError<V>>
Replaces the attribute of a vertex with a new value, returning the old one.
If the vertex does not exist, an error is returned.
Sourcefn replace_vertex(&mut self, id: &Self::VertexId, vertex: V) -> V
fn replace_vertex(&mut self, id: &Self::VertexId, vertex: V) -> V
Replaces the attribute of a vertex with a new value, returning the old one.
§Panics
Panics if the vertex does not exist.
Sourcefn try_replace_edge(
&mut self,
id: &Self::EdgeId,
edge: E,
) -> Result<E, ReplaceEdgeError<E>>
fn try_replace_edge( &mut self, id: &Self::EdgeId, edge: E, ) -> Result<E, ReplaceEdgeError<E>>
Replaces the attribute of an edge with a new value, returning the old one.
If the edge does not exist, an error is returned.
Sourcefn replace_edge(&mut self, id: &Self::EdgeId, edge: E) -> E
fn replace_edge(&mut self, id: &Self::EdgeId, edge: E) -> E
Replaces the attribute of an edge with a new value, returning the old one.
§Panics
Panics if the edge does not exist.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.