Skip to content

Commit f963430

Browse files
author
Stephan Dilly
committed
add clippy::nursery checks
1 parent 9cff56c commit f963430

File tree

11 files changed

+34
-27
lines changed

11 files changed

+34
-27
lines changed

src/app.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ impl App {
6464
help: HelpComponent::new(&theme),
6565
msg: MsgComponent::new(&theme),
6666
tab: 0,
67-
revlog: Revlog::new(&sender, &theme),
68-
status_tab: Status::new(&sender, &queue, &theme),
69-
stashing_tab: Stashing::new(&sender, &queue, &theme),
67+
revlog: Revlog::new(sender, &theme),
68+
status_tab: Status::new(sender, &queue, &theme),
69+
stashing_tab: Stashing::new(sender, &queue, &theme),
7070
stashlist_tab: StashList::new(&queue, &theme),
7171
queue,
7272
theme,
@@ -191,7 +191,7 @@ impl App {
191191
}
192192

193193
///
194-
pub fn is_quit(&self) -> bool {
194+
pub const fn is_quit(&self) -> bool {
195195
self.do_quit
196196
}
197197

src/components/command.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ pub struct CommandInfo {
5050

5151
impl CommandInfo {
5252
///
53-
pub fn new(
53+
pub const fn new(
5454
text: CommandText,
5555
enabled: bool,
5656
available: bool,
@@ -64,13 +64,13 @@ impl CommandInfo {
6464
}
6565
}
6666
///
67-
pub fn order(self, order: i8) -> Self {
67+
pub const fn order(self, order: i8) -> Self {
6868
let mut res = self;
6969
res.order = order;
7070
res
7171
}
7272
///
73-
pub fn hidden(self) -> Self {
73+
pub const fn hidden(self) -> Self {
7474
let mut res = self;
7575
res.quick_bar = false;
7676
res

src/components/commitlist.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@ impl CommitList {
5858
}
5959

6060
///
61-
pub fn selection(&self) -> usize {
61+
pub const fn selection(&self) -> usize {
6262
self.selection
6363
}
6464

6565
///
66-
pub fn current_size(&self) -> (u16, u16) {
66+
pub const fn current_size(&self) -> (u16, u16) {
6767
self.current_size
6868
}
6969

@@ -73,12 +73,13 @@ impl CommitList {
7373
}
7474

7575
///
76+
#[allow(clippy::missing_const_for_fn)]
7677
pub fn selection_max(&self) -> usize {
7778
self.count_total.saturating_sub(1)
7879
}
7980

8081
///
81-
pub fn tags(&self) -> &Tags {
82+
pub const fn tags(&self) -> &Tags {
8283
&self.tags
8384
}
8485

@@ -242,6 +243,7 @@ impl CommitList {
242243
txt
243244
}
244245

246+
#[allow(clippy::missing_const_for_fn)]
245247
fn relative_selection(&self) -> usize {
246248
self.selection.saturating_sub(self.items.index_offset())
247249
}

src/components/diff.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ impl DiffComponent {
5454
}
5555
}
5656
///
57-
fn can_scroll(&self) -> bool {
57+
const fn can_scroll(&self) -> bool {
5858
self.diff.lines > 1
5959
}
6060
///

src/components/msg.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ impl Component for MsgComponent {
9696
}
9797

9898
impl MsgComponent {
99-
pub fn new(theme: &Theme) -> Self {
99+
pub const fn new(theme: &Theme) -> Self {
100100
Self {
101101
msg: String::new(),
102102
visible: false,

src/components/textinput.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ impl TextInputComponent {
4848
}
4949

5050
///
51-
pub fn get_text(&self) -> &String {
51+
pub const fn get_text(&self) -> &String {
5252
&self.msg
5353
}
5454
}

src/components/utils/filetree.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ pub struct TreeItemInfo {
2323
}
2424

2525
impl TreeItemInfo {
26-
fn new(indent: u8, path: String, full_path: String) -> Self {
26+
const fn new(
27+
indent: u8,
28+
path: String,
29+
full_path: String,
30+
) -> Self {
2731
Self {
2832
indent,
2933
visible: true,
@@ -147,22 +151,22 @@ impl FileTreeItems {
147151
{
148152
let item_path = Path::new(&e.path);
149153

150-
FileTreeItems::push_dirs(
154+
Self::push_dirs(
151155
item_path,
152156
&mut nodes,
153157
&mut paths_added,
154-
&collapsed,
158+
collapsed,
155159
)?;
156160
}
157161

158-
nodes.push(FileTreeItem::new_file(&e)?);
162+
nodes.push(FileTreeItem::new_file(e)?);
159163
}
160164

161165
Ok(Self(nodes))
162166
}
163167

164168
///
165-
pub(crate) fn items(&self) -> &Vec<FileTreeItem> {
169+
pub(crate) const fn items(&self) -> &Vec<FileTreeItem> {
166170
&self.0
167171
}
168172

src/components/utils/logitems.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ impl ItemBatch {
4545
}
4646

4747
///
48-
pub fn index_offset(&self) -> usize {
48+
pub const fn index_offset(&self) -> usize {
4949
self.index_offset
5050
}
5151

src/components/utils/statustree.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ struct SelectionChange {
2929
changes: bool,
3030
}
3131
impl SelectionChange {
32-
fn new(new_index: usize, changes: bool) -> Self {
32+
const fn new(new_index: usize, changes: bool) -> Self {
3333
Self { new_index, changes }
3434
}
3535
}

src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
//https://github.com/crossterm-rs/crossterm/issues/432
55
#![allow(clippy::cargo::multiple_crate_versions)]
66
#![deny(clippy::pedantic)]
7+
#![deny(clippy::nursery)]
78
#![deny(clippy::result_unwrap_used)]
89
#![deny(clippy::panic)]
910
#![allow(clippy::module_name_repetitions)]

0 commit comments

Comments
 (0)