This is the first time I'm actually doing something with lifetimes so I am still a bit confused. But I am trying to create a Graph trait that has a function which requires a lifetime like this:

```
pub trait Graph {
fn add_node<'a,'b:'a>(&'a mut self, node: &'b Node);
}
```

and my implementation of this trait looks like this:

```
pub struct StandardGraph<'a> {
nodes: Vec<&'a Node>,
}
impl<'a> Graph for StandardGraph<'a> {
fn add_node<'b:'a> (&'a mut self, node: &'b Node) {
self.nodes.push(node);
}
}
```

However the compiler complains that the lifetimes in impl do not match this method in trait, which makes sense to me but if I try to implement it with <'a,'b:'a> then I get an error that lifetime 'a is already in scope. I've tried a bunch of possible ways to do this but there is something wrong with all of them.

Is there a solution to this problem without adding a lifetime to the trait ?

The problem with adding a lifetime to the trait is that I also have the following trait

```
pub trait ComponentsAlgorithm<G:Graph> {
fn get_components(&self, graph: &G) -> Vec<HashSet<i32>>;
}
pub struct ComponentsAlgorithmOptions<G:Graph> {
pub components_algorithm: Box<dyn ComponentsAlgorithm<G>>,
}
impl<G:Graph> ComponentsAlgorithmOptions<G> {
pub fn new(algorithm_type: AlgorithmType) -> Self {
let components_algorithm = create_components_algorithm(&algorithm_type);
ComponentsAlgorithmOptions{
components_algorithm,
}
}
}
```

and the lifetime would force the ComponentsAlgorithm to only live as long as the graph if I understand everything correctly.

However since the ComponentsAlgorithm is actually independent of the graph this doesn't seem to make much sense to me. Or is there something conceptually wrong with the second trait ?