Skip to content

Commit

Permalink
clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
spoorn committed Dec 10, 2022
1 parent d6f6105 commit 656920e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion bench/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ pub fn setup(num_clients: u32, start_port: u32) -> (Vec<PacketManager>, PacketMa
(client_managers, server_manager)
}

pub fn sync_example_multiclient_server(client_managers: &mut Vec<PacketManager>, server_manager: &mut PacketManager) {
pub fn sync_example_multiclient_server(client_managers: &mut [PacketManager], server_manager: &mut PacketManager) {
let server_addr = "127.0.0.1:5000";

// broadcast packets to all recipients, and receive all packets from sender
Expand Down
3 changes: 3 additions & 0 deletions durian/src/packet.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::type_complexity)]

use std::any::{type_name, Any, TypeId};
use std::error::Error;
use std::fmt::Debug;
Expand Down Expand Up @@ -324,6 +326,7 @@ impl PacketManager {
///
/// # Panic
/// If the [`Runtime`] could not be created. Usually happens if you call `new()` from an existing async runtime.
#[allow(clippy::new_without_default)]
pub fn new() -> Self {
let runtime = tokio::runtime::Builder::new_multi_thread().enable_all().build();
match runtime {
Expand Down
6 changes: 5 additions & 1 deletion durian_macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ pub fn bincode_packet(_attr: TokenStream, tokens: TokenStream) -> TokenStream {
panic!("Struct annotated with #[bincode_packet] and has named fields cannot have empty number of fields")
}
// See https://github.com/serde-rs/serde/issues/1465 for why serde macro is needed
#[allow(clippy::needless_return)]
return quote! {
#[derive(durian::serde::Serialize, durian::serde::Deserialize, durian::BinPacket)]
#[serde(crate = "durian::serde")]
Expand All @@ -87,6 +88,7 @@ pub fn bincode_packet(_attr: TokenStream, tokens: TokenStream) -> TokenStream {
.into();
}
Fields::Unit => {
#[allow(clippy::needless_return)]
return quote! {
#[derive(durian::UnitPacket)]
#input
Expand Down Expand Up @@ -139,6 +141,7 @@ pub fn bin_packet(tokens: TokenStream) -> TokenStream {
let name = input.ident;
let packet_builder_name = Ident::new((name.to_string() + "PacketBuilder").as_str(), Span::call_site());

#[allow(clippy::needless_return)]
return quote! {
impl durian::Packet for #name {
fn as_bytes(&self) -> durian::bytes::Bytes {
Expand Down Expand Up @@ -192,6 +195,7 @@ pub fn unit_packet(tokens: TokenStream) -> TokenStream {
let name_str = format!("\"{}\"", name);
let packet_builder_name = Ident::new((name.to_string() + "PacketBuilder").as_str(), Span::call_site());

#[allow(clippy::needless_return)]
return quote! {
impl durian::Packet for #name {
fn as_bytes(&self) -> durian::bytes::Bytes {
Expand Down Expand Up @@ -229,7 +233,7 @@ pub fn error_only_message(tokens: TokenStream) -> TokenStream {

let mut has_message = false;
for field in fields_punct.iter() {
if field.ident.as_ref().unwrap().to_string() == "message".to_string() {
if *field.ident.as_ref().unwrap() == *"message" {
has_message = true;
break;
}
Expand Down

0 comments on commit 656920e

Please # to comment.