cargo clippy --fix --all-targets (clippy 1.66)

This is exclusively (if I look correctly) redundant referencing.
pull/243/head
Matěj Laitl 2023-01-02 16:04:15 +01:00
parent 0062421426
commit 2859684864
7 changed files with 14 additions and 14 deletions

View File

@ -174,7 +174,7 @@ mod tests {
} }
fn setup_basic_store(dir: &Path) { fn setup_basic_store(dir: &Path) {
let mut store = DataStore::open_with_path(&dir.join("peer_store.json"), true).unwrap(); let mut store = DataStore::open_with_path(dir.join("peer_store.json"), true).unwrap();
println!("{:?}", store); println!("{:?}", store);
assert_eq!(0, store.peers().len()); assert_eq!(0, store.peers().len());
@ -189,7 +189,7 @@ mod tests {
fn test_sanity() { fn test_sanity() {
let dir = tempfile::tempdir().unwrap(); let dir = tempfile::tempdir().unwrap();
setup_basic_store(dir.path()); setup_basic_store(dir.path());
let store = DataStore::open_with_path(&dir.path().join("peer_store.json"), false).unwrap(); let store = DataStore::open_with_path(dir.path().join("peer_store.json"), false).unwrap();
assert_eq!(store.peers(), &*BASE_PEERS); assert_eq!(store.peers(), &*BASE_PEERS);
assert_eq!(store.cidrs(), &*BASE_CIDRS); assert_eq!(store.cidrs(), &*BASE_CIDRS);
} }
@ -199,7 +199,7 @@ mod tests {
let dir = tempfile::tempdir().unwrap(); let dir = tempfile::tempdir().unwrap();
setup_basic_store(dir.path()); setup_basic_store(dir.path());
let mut store = let mut store =
DataStore::open_with_path(&dir.path().join("peer_store.json"), false).unwrap(); DataStore::open_with_path(dir.path().join("peer_store.json"), false).unwrap();
// Should work, since peer is unmodified. // Should work, since peer is unmodified.
store.update_peers(&BASE_PEERS).unwrap(); store.update_peers(&BASE_PEERS).unwrap();
@ -216,7 +216,7 @@ mod tests {
let dir = tempfile::tempdir().unwrap(); let dir = tempfile::tempdir().unwrap();
setup_basic_store(dir.path()); setup_basic_store(dir.path());
let mut store = let mut store =
DataStore::open_with_path(&dir.path().join("peer_store.json"), false).unwrap(); DataStore::open_with_path(dir.path().join("peer_store.json"), false).unwrap();
// Should work, since peer is unmodified. // Should work, since peer is unmodified.
store.update_peers(&[]).unwrap(); store.update_peers(&[]).unwrap();

View File

@ -117,7 +117,7 @@ impl HostsBuilder {
/// Inserts a new section to the system's default hosts file. If there is a section with the /// Inserts a new section to the system's default hosts file. If there is a section with the
/// same tag name already, it will be replaced with the new list instead. /// same tag name already, it will be replaced with the new list instead.
pub fn write(&self) -> io::Result<()> { pub fn write(&self) -> io::Result<()> {
self.write_to(&Self::default_path()?) self.write_to(Self::default_path()?)
} }
/// Returns the default hosts path based on the current OS. /// Returns the default hosts path based on the current OS.

View File

@ -49,7 +49,7 @@ mod handlers {
let conn = session.context.db.lock(); let conn = session.context.db.lock();
let auths = DatabaseAssociation::list(&conn)?; let auths = DatabaseAssociation::list(&conn)?;
json_response(&auths) json_response(auths)
} }
pub async fn delete(id: i64, session: Session) -> Result<Response<Body>, ServerError> { pub async fn delete(id: i64, session: Session) -> Result<Response<Body>, ServerError> {

View File

@ -40,14 +40,14 @@ mod handlers {
let cidr = DatabaseCidr::create(&conn, contents)?; let cidr = DatabaseCidr::create(&conn, contents)?;
json_status_response(&cidr, StatusCode::CREATED) json_status_response(cidr, StatusCode::CREATED)
} }
pub async fn list(session: Session) -> Result<Response<Body>, ServerError> { pub async fn list(session: Session) -> Result<Response<Body>, ServerError> {
let conn = session.context.db.lock(); let conn = session.context.db.lock();
let cidrs = DatabaseCidr::list(&conn)?; let cidrs = DatabaseCidr::list(&conn)?;
json_response(&cidrs) json_response(cidrs)
} }
pub async fn delete(id: i64, session: Session) -> Result<Response<Body>, ServerError> { pub async fn delete(id: i64, session: Session) -> Result<Response<Body>, ServerError> {

View File

@ -178,7 +178,7 @@ pub fn init_wizard(conf: &ServerConfig, opts: InitializeOpts) -> Result<(), Erro
address: our_ip, address: our_ip,
network_cidr_prefix: root_cidr.prefix_len(), network_cidr_prefix: root_cidr.prefix_len(),
}; };
config.write_to_path(&config_path)?; config.write_to_path(config_path)?;
let db_init_data = DbInitData { let db_init_data = DbInitData {
network_name: name.to_string(), network_name: name.to_string(),

View File

@ -103,7 +103,7 @@ impl Server {
let interface = interface.parse().unwrap(); let interface = interface.parse().unwrap();
// Add developer CIDR and user CIDR and some peers for testing. // Add developer CIDR and user CIDR and some peers for testing.
let db = Connection::open(&conf.database_path(&interface))?; let db = Connection::open(conf.database_path(&interface))?;
db.pragma_update(None, "foreign_keys", 1)?; db.pragma_update(None, "foreign_keys", 1)?;
assert_eq!(ADMIN_CIDR_ID, create_cidr(&db, "admin", ADMIN_CIDR)?.id); assert_eq!(ADMIN_CIDR_ID, create_cidr(&db, "admin", ADMIN_CIDR)?.id);
assert_eq!( assert_eq!(

View File

@ -27,14 +27,14 @@ fn get_base_folder() -> io::Result<PathBuf> {
} }
fn get_namefile(name: &InterfaceName) -> io::Result<PathBuf> { fn get_namefile(name: &InterfaceName) -> io::Result<PathBuf> {
Ok(get_base_folder()?.join(&format!("{}.name", name.as_str_lossy()))) Ok(get_base_folder()?.join(format!("{}.name", name.as_str_lossy())))
} }
fn get_socketfile(name: &InterfaceName) -> io::Result<PathBuf> { fn get_socketfile(name: &InterfaceName) -> io::Result<PathBuf> {
if cfg!(target_os = "linux") { if cfg!(target_os = "linux") {
Ok(get_base_folder()?.join(&format!("{}.sock", name))) Ok(get_base_folder()?.join(format!("{}.sock", name)))
} else { } else {
Ok(get_base_folder()?.join(&format!("{}.sock", resolve_tun(name)?))) Ok(get_base_folder()?.join(format!("{}.sock", resolve_tun(name)?)))
} }
} }
@ -273,7 +273,7 @@ fn get_userspace_implementation() -> String {
} }
fn start_userspace_wireguard(iface: &InterfaceName) -> io::Result<Output> { fn start_userspace_wireguard(iface: &InterfaceName) -> io::Result<Output> {
let mut command = Command::new(&get_userspace_implementation()); let mut command = Command::new(get_userspace_implementation());
let output = if cfg!(target_os = "linux") { let output = if cfg!(target_os = "linux") {
command.args(&[iface.to_string()]).output()? command.args(&[iface.to_string()]).output()?
} else { } else {