Skip to content

Commit

Permalink
final clippy fixes (#47)
Browse files Browse the repository at this point in the history
* final clippy fix

* Auto Format Changes

* add clippy check

---------

Co-authored-by: Format Bot <>
  • Loading branch information
hazel-sudz authored Dec 15, 2024
1 parent 36f8425 commit a0d6578
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 11 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/clippy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Run Clippy Check
on:
push:
branches:
- 'main'
pull_request:
branches:
- '*'
workflow_dispatch:

jobs:
test:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
runs-on: ${{matrix.os}}

steps:
- uses: actions/checkout@v4

- name: Install Rust
run: |
rustup update
- name: Run Clippy Check
run: |
cargo clippy -- -Dwarnings
3 changes: 1 addition & 2 deletions src/messages/responses/write_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ impl MessagePayload for WriteResponse {
}

fn serialize(&self) -> Result<Vec<u8>> {
let mut buffer = Vec::new();
buffer.push(self.error);
let buffer = vec![self.error];
Ok(buffer)
}

Expand Down
17 changes: 8 additions & 9 deletions src/read_shard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,17 @@ impl RouterHandler for ReadShard {
);
let key = String::from_utf8_lossy(&req.key).into_owned();
let value = self.data.lock().unwrap().get(&key).cloned();
if value.is_none() {
ReadResponse {
match value {
Some(value) => ReadResponse {
error: 0,
key: req.key.clone(),
value: value.into_bytes(),
},
None => ReadResponse {
error: 1,
key: req.key.clone(),
value: Vec::new(),
}
} else {
ReadResponse {
error: 0,
key: req.key.clone(),
value: value.unwrap().into_bytes(),
}
},
}
}

Expand Down
1 change: 1 addition & 0 deletions src/utils/test_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ impl TestRouterClient {
}
}

#[allow(unused)]
pub fn get_client(&self) -> RouterClient<TestRouterClientHandler> {
self.router.get_router_client()
}
Expand Down

0 comments on commit a0d6578

Please sign in to comment.