Skip to content

Commit

Permalink
chore: clippy lint on CI
Browse files Browse the repository at this point in the history
  • Loading branch information
wolf4ood committed Sep 21, 2024
1 parent fcb85c4 commit 0e26b30
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 12 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ jobs:
os: [ubuntu-latest]
rust: [stable]
steps:

- uses: actions/checkout@v2
- name: Starting EDC Servers
run: |
Expand All @@ -38,8 +37,15 @@ jobs:
with:
command: fmt
args: --all -- --check

- name: Run cargo clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: --all -- -D warnings

- name: Run cargo test with tokio
uses: actions-rs/cargo@v1
with:
command: test
args: --manifest-path edc-connector-client/Cargo.toml
args: --manifest-path edc-connector-client/Cargo.toml
2 changes: 1 addition & 1 deletion edc-connector-tui/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ impl Component for App {
&mut self,
msg: ComponentMsg<Self::Msg>,
) -> anyhow::Result<ComponentReturn<AppMsg>> {
match msg.to_owned() {
match msg.take() {
AppMsg::ConnectorsMsg(m) => {
Self::forward_update::<_, ConnectorsComponent>(
&mut self.connectors,
Expand Down
3 changes: 2 additions & 1 deletion edc-connector-tui/src/components.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,8 @@ pub enum NotificationKind {
}

impl<T> ComponentMsg<T> {
pub fn to_owned(self) -> T {

pub fn take(self) -> T {
self.0
}

Expand Down
2 changes: 1 addition & 1 deletion edc-connector-tui/src/components/connectors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ impl Component for ConnectorsComponent {
&mut self,
msg: ComponentMsg<Self::Msg>,
) -> anyhow::Result<ComponentReturn<Self::Msg>> {
match msg.to_owned() {
match msg.take() {
ConnectorsMsg::ConnectorSelected(connector) => {
self.selected = Some(connector.clone());
Ok(ComponentReturn::action(Action::NavTo(Nav::AssetsList)))
Expand Down
2 changes: 1 addition & 1 deletion edc-connector-tui/src/components/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ impl Component for HeaderComponent {
&mut self,
msg: ComponentMsg<Self::Msg>,
) -> anyhow::Result<ComponentReturn<Self::Msg>> {
match msg.to_owned() {
match msg.take() {
HeaderMsg::NextTab => {
let current = self.menu.clone();
let idx = (self.menu.ordinal() + 1) % Menu::VALUES.len();
Expand Down
2 changes: 1 addition & 1 deletion edc-connector-tui/src/components/launch_bar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl Component for LaunchBar {
&mut self,
msg: ComponentMsg<Self::Msg>,
) -> anyhow::Result<ComponentReturn<Self::Msg>> {
match msg.to_owned() {
match msg.take() {
LaunchBarMsg::AppendCommand(input) => {
self.area.input(input);
Ok(ComponentReturn::empty())
Expand Down
2 changes: 1 addition & 1 deletion edc-connector-tui/src/components/resources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ impl<T: DrawableResource + TableEntry + Send + Sync> Component for ResourcesComp
&mut self,
msg: ComponentMsg<Self::Msg>,
) -> anyhow::Result<ComponentReturn<Self::Msg>> {
match msg.to_owned() {
match msg.take() {
ResourcesMsg::ResourceSelected(selected) => {
self.resource.update_resource(Some(selected));
self.focus = Focus::Resource;
Expand Down
2 changes: 1 addition & 1 deletion edc-connector-tui/src/components/resources/resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ impl<T: DrawableResource + Send> Component for ResourceComponent<T> {
&mut self,
message: ComponentMsg<Self::Msg>,
) -> anyhow::Result<ComponentReturn<Self::Msg>> {
match message.to_owned() {
match message.take() {
ResourceMsg::MoveUp => self.move_up(),
ResourceMsg::MoveDown => self.move_down(),
ResourceMsg::Yank => self.yank(),
Expand Down
8 changes: 5 additions & 3 deletions edc-connector-tui/src/components/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ use self::msg::{TableLocalMsg, TableMsg};

use super::{Component, ComponentEvent, ComponentMsg, ComponentReturn};

pub type OnSelect<T, M> = Box<dyn Fn(&T) -> M + Send + Sync>;

pub struct UiTable<T: TableEntry, M> {
name: String,
pub elements: Vec<T>,
table_state: TableState,
on_select: Option<Box<dyn Fn(&T) -> M + Send + Sync>>,
on_select: Option<OnSelect<T, M>>,
}

impl<T: TableEntry + Debug, M> Debug for UiTable<T, M> {
Expand Down Expand Up @@ -79,7 +81,7 @@ impl<T: TableEntry + Send, M: Send> Component for UiTable<T, M> {
&mut self,
msg: ComponentMsg<Self::Msg>,
) -> anyhow::Result<ComponentReturn<Self::Msg>> {
match msg.to_owned() {
match msg.take() {
TableMsg::Local(TableLocalMsg::MoveDown) => self.move_down(),
TableMsg::Local(TableLocalMsg::MoveUp) => self.move_up(),
TableMsg::Outer(_) => {}
Expand Down Expand Up @@ -151,7 +153,7 @@ impl<T: TableEntry, M> UiTable<T, M> {

fn move_up(&mut self) {
let new_pos = match self.table_state.selected() {
Some(i) if i == 0 => self.elements.len() - 1,
Some(0) => self.elements.len() - 1,
Some(i) => i - 1,
None => 0,
};
Expand Down

0 comments on commit 0e26b30

Please sign in to comment.