File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -18,9 +18,34 @@ pub enum Version {
18
18
Http3_0 ,
19
19
}
20
20
21
+ impl std:: fmt:: Display for Version {
22
+ fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
23
+ f. write_str ( match self {
24
+ Version :: Http0_9 => "HTTP/0.9" ,
25
+ Version :: Http1_0 => "HTTP/1.0" ,
26
+ Version :: Http1_1 => "HTTP/1.1" ,
27
+ Version :: Http2_0 => "HTTP/2.0" ,
28
+ Version :: Http3_0 => "HTTP/3.0" ,
29
+ } )
30
+ }
31
+ }
32
+
21
33
#[ cfg( test) ]
22
34
mod test {
23
35
use super :: * ;
36
+ #[ test]
37
+ fn to_string ( ) {
38
+ let output = format ! (
39
+ "{} {} {} {} {}" ,
40
+ Version :: Http0_9 ,
41
+ Version :: Http1_0 ,
42
+ Version :: Http1_1 ,
43
+ Version :: Http2_0 ,
44
+ Version :: Http3_0
45
+ ) ;
46
+ assert_eq ! ( "HTTP/0.9 HTTP/1.0 HTTP/1.1 HTTP/2.0 HTTP/3.0" , output) ;
47
+ }
48
+
24
49
#[ test]
25
50
fn ord ( ) {
26
51
use Version :: * ;
You can’t perform that action at this time.
0 commit comments