Skip to content

Commit

Permalink
🚨 Implement Display for Cookie instead of ToString
Browse files Browse the repository at this point in the history
```
error: direct implementation of `ToString`
   --> src/bus/cookies.rs:222:1
    |
222 | / impl ToString for Cookie {
223 | |     fn to_string(&self) -> String {
224 | |         format!("{} {} {}", self.id, self.created, self.cookie)
225 | |     }
226 | | }
    | |_^
    |
    = help: prefer implementing `Display` instead
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#to_string_trait_impl
    = note: `-D clippy::to-string-trait-impl` implied by `-D warnings`
    = help: to override `-D warnings` add `#[allow(clippy::to_string_trait_impl)]`
```
  • Loading branch information
Zeeshan Ali Khan committed Feb 10, 2024
1 parent 54aff3a commit ff0338d
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/bus/cookies.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
use anyhow::{anyhow, Error, Result};
use rand::Rng;
#[cfg(unix)]
use std::{fs::Permissions, os::unix::prelude::PermissionsExt};
use std::{
fmt::{self, Display, Formatter},
io,
str::FromStr,
time::{Duration, SystemTime, UNIX_EPOCH},
};
#[cfg(unix)]
use std::{fs::Permissions, os::unix::prelude::PermissionsExt};
#[cfg(unix)]
use tokio::fs::set_permissions;
use tokio::{
fs::{create_dir_all, metadata, remove_file, rename, File, OpenOptions},
Expand Down Expand Up @@ -219,9 +220,9 @@ impl FromStr for Cookie {
}
}

impl ToString for Cookie {
fn to_string(&self) -> String {
format!("{} {} {}", self.id, self.created, self.cookie)
impl Display for Cookie {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
write!(f, "{} {} {}", self.id, self.created, self.cookie)
}
}

Expand Down

0 comments on commit ff0338d

Please sign in to comment.