Skip to content

Commit 54c4ed5

Browse files
authored
Update managing-colors-in-rust.md
1 parent 06b13f9 commit 54c4ed5

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/managing-colors-in-rust.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ And finally, here's the binary code that uses the library.
5252

5353
Notes:
5454
* **Library code is completely unaware of whether the environment supports colors.** All it cares about is whether the `colorize` method is called.
55-
* Note that the global `set_override` and `unset_override` methods have no impact on library code in the example above, since it is only active if `if_supports_color` is called as in the immediate pattern above.
55+
* Note that the global `set_override` and `unset_override` methods have no impact on library code in the stylesheet example.
56+
* The global methods are only active if `if_supports_color` is called, as shown by the example for the immediate pattern above. This is by design: most libraries shouldn't reach out to global state.
5657
* **The stylesheet is stored as `Box<Styles>`.** The boxing isn't strictly required, but each `Style` is pretty large, and a struct containing e.g. 16 styles is 272 bytes as of owo-colors 3.2.0. That's a pretty large amount of data to store on the stack.
5758
* **`Styles::default()` initializes all the styles to having no effect.** The `colorize()` method then initializes them as required.
5859
* **For custom color support, `Styles` can be made public.** Most library code won't need to give users the ability to customize styles, but this pattern naturally extends to that use case.

0 commit comments

Comments
 (0)