Fix clippy and remove borrows

Fix clippy lints and remove unneded borrows when logging or printing
macros.
This commit is contained in:
finga 2021-12-03 14:57:38 +01:00
parent 1aab989000
commit 8f93d2d6c8
6 changed files with 15 additions and 15 deletions

View file

@ -40,7 +40,7 @@ impl Create {
let mq = &mut posixmq::OpenOptions::readonly();
if let Some(m) = &self.mode {
mq.mode(u32::from_str_radix(&m, 8)?);
mq.mode(u32::from_str_radix(m, 8)?);
}
mq.max_msg_len(self.msgsize.unwrap_or_else(msgsize_default))
@ -53,10 +53,10 @@ impl Create {
let attributes = mq.attributes()?;
info!("Created message queue: {} with attributes msgsize: {}, capacity: {}, current_messages: {}",
&self.queue,
&attributes.max_msg_len,
&attributes.capacity,
&attributes.current_messages);
self.queue,
attributes.max_msg_len,
attributes.capacity,
attributes.current_messages);
}
Ok(())

View file

@ -16,7 +16,7 @@ impl Info {
println!(
"Message queue: {}, msg_max: {}, msgsize_max: {}, current_messages: {}",
&self.queue, &attrs.capacity, &attrs.max_msg_len, &attrs.current_messages
self.queue, attrs.capacity, attrs.max_msg_len, attrs.current_messages
);
Ok(())

View file

@ -38,24 +38,24 @@ impl Send {
if let Some(timeout) = &self.timeout {
mq.open(&self.queue)?.send_timeout(
self.priority,
&self.msg.as_bytes(),
self.msg.as_bytes(),
*timeout.parse::<Duration>()?,
)?;
info!("Sent message: \"{}\" to queue: {}", &self.msg, &self.queue);
info!("Sent message: \"{}\" to queue: {}", self.msg, self.queue);
} else if let Some(deadline) = &self.deadline {
mq.open(&self.queue)?.send_deadline(
self.priority,
&self.msg.as_bytes(),
self.msg.as_bytes(),
DateTime::parse_from_str(deadline, "%Y-%m-%d %H:%M:%S")?.into(),
)?;
info!("Sent message: \"{}\" to queue: {}", &self.msg, &self.queue);
info!("Sent message: \"{}\" to queue: {}", self.msg, self.queue);
} else {
mq.open(&self.queue)?
.send(self.priority, &self.msg.as_bytes())?;
.send(self.priority, self.msg.as_bytes())?;
info!("Sent message: \"{}\" to queue: {}", &self.msg, &self.queue);
info!("Sent message: \"{}\" to queue: {}", self.msg, self.queue);
}
Ok(())

View file

@ -14,7 +14,7 @@ impl Unlink {
pub fn run(&self) -> Result<()> {
posixmq::remove_queue(&self.queue)?;
info!("Removed message queue: {}", &self.queue);
info!("Removed message queue: {}", self.queue);
Ok(())
}

View file

@ -19,7 +19,7 @@ impl Create {
let mut mq = SysvMq::<String>::new();
if let Some(m) = &self.mode {
mq.mode(i32::from_str_radix(&m, 8)?);
mq.mode(i32::from_str_radix(m, 8)?);
}
mq.create(self.key)?;

View file

@ -28,7 +28,7 @@ impl Info {
pub fn run(&self) -> Result<()> {
let mut lines = BufReader::new(File::open("/proc/sysvipc/msg")?).lines();
print_line(&lines.nth(0).unwrap_or(Ok(String::new()))?);
print_line(&lines.next().unwrap_or_else(|| Ok(String::new()))?);
for line in lines {
let line = line?;