@@ -5,14 +5,14 @@ use crate::chroot::Chroot;
5
5
use crate :: error:: Error ;
6
6
use crate :: util:: { Ref , ToRef } ;
7
7
8
- #[ derive( Debug , Clone , PartialEq , Eq ) ]
8
+ #[ derive( Clone , PartialEq , Eq ) ]
9
9
pub struct Endpoint {
10
10
pub host : String ,
11
11
pub port : u16 ,
12
12
pub tls : bool ,
13
13
}
14
14
15
- #[ derive( Debug , Copy , Clone , PartialEq , Eq ) ]
15
+ #[ derive( Copy , Clone , PartialEq , Eq ) ]
16
16
pub struct EndpointRef < ' a > {
17
17
pub host : & ' a str ,
18
18
pub port : u16 ,
@@ -37,6 +37,12 @@ impl Display for Endpoint {
37
37
}
38
38
}
39
39
40
+ impl fmt:: Debug for Endpoint {
41
+ fn fmt ( & self , f : & mut Formatter < ' _ > ) -> fmt:: Result {
42
+ Display :: fmt ( self , f)
43
+ }
44
+ }
45
+
40
46
impl < ' a > From < ( & ' a str , u16 , bool ) > for EndpointRef < ' a > {
41
47
fn from ( v : ( & ' a str , u16 , bool ) ) -> Self {
42
48
Self :: new ( v. 0 , v. 1 , v. 2 )
@@ -50,6 +56,12 @@ impl Display for EndpointRef<'_> {
50
56
}
51
57
}
52
58
59
+ impl fmt:: Debug for EndpointRef < ' _ > {
60
+ fn fmt ( & self , f : & mut Formatter < ' _ > ) -> fmt:: Result {
61
+ Display :: fmt ( self , f)
62
+ }
63
+ }
64
+
53
65
impl PartialEq < ( & str , u16 , bool ) > for EndpointRef < ' _ > {
54
66
fn eq ( & self , other : & ( & str , u16 , bool ) ) -> bool {
55
67
self . host == other. 0 && self . port == other. 1 && self . tls == other. 2
@@ -380,9 +392,13 @@ mod tests {
380
392
let endpoint = EndpointRef :: new ( "host" , 2181 , false ) ;
381
393
assert_eq ! ( endpoint. to_string( ) , "tcp://host:2181" ) ;
382
394
assert_eq ! ( endpoint. to_value( ) . to_string( ) , "tcp://host:2181" ) ;
395
+ assert_eq ! ( format!( "{:?}" , endpoint) , "tcp://host:2181" ) ;
396
+ assert_eq ! ( format!( "{:?}" , endpoint. to_value( ) ) , "tcp://host:2181" ) ;
383
397
384
398
let endpoint = EndpointRef :: new ( "host" , 2182 , true ) ;
385
399
assert_eq ! ( endpoint. to_string( ) , "tcp+tls://host:2182" ) ;
386
400
assert_eq ! ( endpoint. to_value( ) . to_string( ) , "tcp+tls://host:2182" ) ;
401
+ assert_eq ! ( format!( "{:?}" , endpoint) , "tcp+tls://host:2182" ) ;
402
+ assert_eq ! ( format!( "{:?}" , endpoint. to_value( ) ) , "tcp+tls://host:2182" ) ;
387
403
}
388
404
}
0 commit comments