File tree Expand file tree Collapse file tree 5 files changed +19
-11
lines changed
Expand file tree Collapse file tree 5 files changed +19
-11
lines changed Original file line number Diff line number Diff line change 2020 checks : write
2121 pull-requests : write
2222 security-events : write
23-
24- env :
25- CLICOLOR_FORCE : 1
26- COLORTERM : truecolor
27- TERM : xterm-256color
2823
2924 steps :
3025 - name : Checkout Repository
Original file line number Diff line number Diff line change @@ -11,4 +11,4 @@ edition = "2018"
1111
1212[workspace .dependencies ]
1313cfg-if = " 1.0"
14- maybe-impl = " 0.1.0 "
14+ maybe-impl = " 0.1"
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ optional = true
3737
3838[dependencies ]
3939cfg-if.workspace = true
40- colored = { version = " 2.0 " , optional = true }
40+ colored = { version = " 3.1 " , optional = true }
4141
4242[dev-dependencies .more-di ]
4343path = " ."
Original file line number Diff line number Diff line change @@ -438,11 +438,15 @@ impl std::fmt::Debug for ServiceCollection {
438438
439439impl std:: fmt:: Display for ServiceCollection {
440440 fn fmt ( & self , f : & mut Formatter < ' _ > ) -> FormatResult {
441- if f. alternate ( ) && cfg ! ( feature = "fmt" ) {
442- fmt:: write ( self , fmt:: terminal:: Renderer , f)
443- } else {
444- fmt:: write ( self , fmt:: text:: Renderer , f)
441+ cfg_if:: cfg_if! {
442+ if #[ cfg( feature = "fmt" ) ] {
443+ if f. alternate( ) {
444+ return fmt:: write( self , fmt:: terminal:: Renderer , f) ;
445+ }
446+ }
445447 }
448+
449+ fmt:: write ( self , fmt:: text:: Renderer , f)
446450 }
447451}
448452
Original file line number Diff line number Diff line change 22
33use crate :: traits:: * ;
44use di:: * ;
5+ use std:: env:: set_var;
56
67#[ injectable]
78struct A ;
@@ -152,6 +153,12 @@ const TEXT_TERMINAL: &str =
152153 └ [38;2;75;154;214mdyn[0m [38;2;158;211;163mmore_di_tests::traits::Thing[0m → [38;2;78;201;176mmore_di_tests::format::Thing3[0m [38;2;118;118;118m[Scoped][0m\n \
153154 └ [38;2;78;201;176mmore_di_tests::format::A[0m → [38;2;78;201;176mmore_di_tests::format::A[0m [38;2;118;118;118m[Singleton][0m\n ";
154155
156+ fn force_color_support ( ) {
157+ set_var ( "CLICOLOR_FORCE" , "1" ) ;
158+ set_var ( "COLORTERM" , "truecolor" ) ;
159+ set_var ( "TERM" , "xterm-256color" ) ;
160+ }
161+
155162#[ test]
156163fn debug_should_format_service_collection ( ) {
157164 // arrange
@@ -181,6 +188,8 @@ fn alt_display_should_format_service_collection() {
181188 // arrange
182189 let services = new_service_collection ( ) ;
183190
191+ force_color_support ( ) ;
192+
184193 // act
185194 let output = format ! ( "{services:#}" ) ;
186195
You can’t perform that action at this time.
0 commit comments