File tree Expand file tree Collapse file tree 1 file changed +24
-7
lines changed Expand file tree Collapse file tree 1 file changed +24
-7
lines changed Original file line number Diff line number Diff line change 1
1
use displaydoc:: Display ;
2
- // use std::path::PathBuf;
2
+
3
+ #[ cfg( feature = "std" ) ]
4
+ use std:: path:: PathBuf ;
5
+
6
+ #[ derive( Display ) ]
7
+ /// Just a basic struct {thing}
8
+ struct HappyStruct {
9
+ thing : & ' static str ,
10
+ }
3
11
4
12
#[ derive( Display ) ]
5
13
enum Happy {
@@ -18,8 +26,10 @@ enum Happy {
18
26
/// Variant5 just has {0} many problems
19
27
/// but multi line comments aren't one of them
20
28
Variant5 ( u32 ) ,
21
- // /// The path {0.display()}
22
- // Variant6(PathBuf),
29
+
30
+ /// The path {0}
31
+ #[ cfg( feature = "std" ) ]
32
+ Variant6 ( PathBuf ) ,
23
33
}
24
34
25
35
fn assert_display < T : std:: fmt:: Display > ( input : T , expected : & ' static str ) {
@@ -37,8 +47,15 @@ fn does_it_print() {
37
47
"Variant4 wants to have a lot of lines\n \n Lets see how this works out for it" ,
38
48
) ;
39
49
assert_display ( Happy :: Variant5 ( 2 ) , "Variant5 just has 2 many problems" ) ;
40
- // assert_display(
41
- // Happy::Variant6(PathBuf::from("/var/log/happy")),
42
- // "The path /var/log/happy",
43
- // );
50
+
51
+ assert_display ( HappyStruct { thing : "hi" } , "Just a basic struct hi" ) ;
52
+ }
53
+
54
+ #[ test]
55
+ #[ cfg( feature = "std" ) ]
56
+ fn does_it_print_path ( ) {
57
+ assert_display (
58
+ Happy :: Variant6 ( PathBuf :: from ( "/var/log/happy" ) ) ,
59
+ "The path /var/log/happy" ,
60
+ ) ;
44
61
}
You can’t perform that action at this time.
0 commit comments