@@ -2,7 +2,7 @@ use std::borrow::Cow;
2
2
use std:: env:: var_os;
3
3
use std:: fs:: File ;
4
4
use std:: io:: { BufRead , BufReader } ;
5
- use std:: path:: PathBuf ;
5
+ use std:: path:: { Path , PathBuf } ;
6
6
7
7
/// try to load a password from the various pgpass file locations
8
8
pub fn load_password (
@@ -14,7 +14,7 @@ pub fn load_password(
14
14
let custom_file = var_os ( "PGPASSFILE" ) ;
15
15
if let Some ( file) = custom_file {
16
16
if let Some ( password) =
17
- load_password_from_file ( PathBuf :: from ( file) , host, port, username, database)
17
+ load_password_from_file ( & PathBuf :: from ( file) , host, port, username, database)
18
18
{
19
19
return Some ( password) ;
20
20
}
@@ -30,18 +30,18 @@ pub fn load_password(
30
30
. ok ( )
31
31
. map ( |basedirs| basedirs. data_dir ( ) . join ( "postgres" ) . join ( "pgpass.conf" ) )
32
32
} ;
33
- load_password_from_file ( default_file?, host, port, username, database)
33
+ load_password_from_file ( & default_file?, host, port, username, database)
34
34
}
35
35
36
36
/// try to extract a password from a pgpass file
37
37
fn load_password_from_file (
38
- path : PathBuf ,
38
+ path : & Path ,
39
39
host : & str ,
40
40
port : u16 ,
41
41
username : & str ,
42
42
database : Option < & str > ,
43
43
) -> Option < String > {
44
- let file = File :: open ( & path)
44
+ let file = File :: open ( path)
45
45
. map_err ( |e| {
46
46
match e. kind ( ) {
47
47
std:: io:: ErrorKind :: NotFound => {
0 commit comments