INDAPlus21 / INDAPlus21/osveijer-sockets

Pass

Open
#1 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Makefile
Stars
0
Forks
0
PR merge metrics
No merged PRs in 30d

Description

**Very well done Oliver!**

Fantastic done! I can only assume that this is a reuse from _DD1337 Programmering_, due to duplication, dead code, among else. For example:

_Your code_:
```rs
match self.selected_square {
Some(pos) => {
if pos == (rank, file) {
self.selected_square = None;
self.highlighted_squares = vec![];
} else if self.highlighted_squares.iter().any(|p| p == &(rank,file)) {
let msg: String = pos_string(pos) + " " + &pos_string((rank,file));
if self.sender.send(msg).is_err() {
println!("crashed");
std::process::exit(1);
}
self.selected_square = None;
self.highlighted_squares = vec![];
} else {
self.selected_square = Some((rank, file));
self.highlighted_squares = vec![];
let c = get_colour(self.game.board[rank][file]);
if c != None {
if c.unwrap() == self.game.active {
self.highlighted_squares = pos_coord_vec(self.game.get_possible_moves(pos_string((rank,file))));
};
};
}
},
None => {
self.selected_square = Some((rank, file));
self.highlighted_squares = Vec::new();
let c = get_colour(self.game.board[rank][file]);
if c != None {
if c.unwrap() == self.game.active {
self.highlighted_squares = pos_coord_vec(self.game.get_possible_moves(pos_string((rank,file))));
};
};
}
}
```
_Refactored code_:
```rs
match self.selected_square {
Some(_pos) if _pos == (rank, file) => {
self.selected_square = None;
self.highlighted_squares = Vec::new();
},
Some(_pos) if self.highlighted_squares.iter().any(|p| p == &(rank,file)) => {
self.selected_square = None;
self.highlighted_squares = Vec::new();

let msg: String = format!("{} {}", pos_string(_pos), &pos_string((rank,file));
if self.sender.send(msg).is_err() {
println!("crashed");
std::process::exit(1);
}
},
_ => {
self.selected_square = Some((rank, file));
self.highlighted_squares = Vec::new();
let c = get_colour(self.game.board[rank][file]);
if c.is_some() && c.unwrap() == self.game.active {
self.highlighted_squares = pos_coord_vec(self.gameget_possible_moves(pos_string((rank,file))));
};
}
}
```

Amazing! Thanks!

Remember:
[![](https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fpeople.via.ecp.fr%2F~enizor%2FformationRust%2Fimages%2Fferris.png&f=1&nofb=1)](https://www.reddit.com/r/rustjerk/)

Keep it up!

Contributor guide

No contributing guide indexed for this repository

Research direction

The issue contains praise and Rust code examples, but it does not identify a requested change, file, test, or acceptance criteria. Start by determining whether this is intended as a refactoring task; there is no stated definition of done or test to run.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
networking
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
10/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.