First serious attempt to fix issue #2 https://github.com/KarlHeitmann/git_explorer/issues/2#3
First serious attempt to fix issue #2 https://github.com/KarlHeitmann/git_explorer/issues/2#3KarlHeitmann wants to merge 1 commit intorefactor_explorerfrom
Conversation
| stop_condition_i: usize, | ||
| stop_conditions: Vec<Option<BranchData>>, | ||
| nodes_len: usize, | ||
| abort: bool, |
There was a problem hiding this comment.
Created abort and limit_stack attributes created in GitExplorer struct, the idea is to remove the arguments here. Separate responsibilities, they are not necessary to be as arguments
| // let branches = branches.map(|b| BranchData::new(b)).collect(); | ||
| self.paint_commit_track(self.repo.head().unwrap().peel_to_commit().unwrap(), branches) | ||
|
|
||
| /* |
There was a problem hiding this comment.
These are all the attempts I made to fix the error[0502] I've got when adding the abort and limit_stack attributes to GitExplorer struct. (lines 177 to 197)
| mut output: Vec<GraphNode>, | ||
| limit_stack: Option<usize>, | ||
| branches: Vec<BranchData>, | ||
| abort: bool) -> Vec<GraphNode> { |
There was a problem hiding this comment.
limit_stack and abort attributes are not necessary as arguments. I can use them from the GitExplorer struct if I define them as attributes of that struct.
|
|
||
| let stop_condition = self.stop_conditions.get(self.stop_condition_i).unwrap(); | ||
| let abort_next = match stop_condition { | ||
| self.abort = match stop_condition { |
There was a problem hiding this comment.
This line will need to mutate GitExplorer instance, and this cascades the error until reaching this point
|
|
||
| fn paint_branch( | ||
| &self, | ||
| &mut self, |
There was a problem hiding this comment.
changed immutable reference to self to mutable reference to self. I also need to change mutable reference to self in paint_commit_track
extracts abort and limit_stack that are the abort conditions to stop drawing the git graph as params to the function, and uses it as attributes of the
GitExplorerstruct