Skip to content

Commit

Permalink
refactor: standarize the use of usize for unsigned integers
Browse files Browse the repository at this point in the history
usize is used in a lot of places in the code by cast os as u32. To
standarize the usage of unsigned integers, usize is going to be used
in detriment of u32.

Closes #35

Signed-off-by: Thiago Duvanel <thiago.duvanel@usp.br>
  • Loading branch information
th-duvanel committed Sep 11, 2024
1 parent c2f380e commit b1a4dd9
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 14 deletions.
8 changes: 1 addition & 7 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,7 @@ impl LatestPatchsetsState {
}

pub fn increment_page(&mut self) {
let patchsets_processed: usize = self
.lore_session
.get_representative_patches_ids()
.len()
.try_into()
.unwrap();
let patchsets_processed: usize = self.lore_session.get_representative_patches_ids().len();
if self.page_size * self.page_number > patchsets_processed {
return;
}
Expand Down Expand Up @@ -399,7 +394,6 @@ impl App {
let target_list = self.mailing_list_selection_state.possible_mailing_lists[list_index]
.get_name()
.to_string();

self.latest_patchsets_state = Some(LatestPatchsetsState::new(
target_list,
self.config.page_size,
Expand Down
5 changes: 1 addition & 4 deletions src/lore_session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,7 @@ impl LoreSession {

pub fn get_patch_feed_page(&self, page_size: usize, page_number: usize) -> Option<Vec<&Patch>> {
let mut patch_feed_page: Vec<&Patch> = Vec::new();
let representative_patches_ids_max_index: usize = (self.representative_patches_ids.len()
- 1)
.try_into()
.unwrap();
let representative_patches_ids_max_index: usize = self.representative_patches_ids.len() - 1;
let lower_end: usize = page_size * (page_number - 1);
let mut upper_end: usize = page_size * page_number;

Expand Down
4 changes: 1 addition & 3 deletions src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,7 @@ fn render_list(f: &mut Frame, app: &App, chunk: Rect) {

let mut list_state = ListState::default();
list_state.select(Some(
(patchset_index - (page_number - 1) * app.config.page_size)
.try_into()
.unwrap(),
patchset_index - (page_number - 1) * app.config.page_size,
));

f.render_stateful_widget(list, chunk, &mut list_state);
Expand Down

0 comments on commit b1a4dd9

Please sign in to comment.