Skip to content

Commit d7ec20b

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

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/managing-colors-in-rust.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,11 @@ And finally, here's the binary code that uses the library.
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.
5555
* 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.
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.
5757
* **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.
5858
* **`Styles::default()` initializes all the styles to having no effect.** The `colorize()` method then initializes them as required.
5959
* **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.
6060
* **Use of a separate `MyAppDisplay` type.** The `colorize` call is isolated to this particular `MyAppDisplay`, without influencing other display calls.
6161
* **`println!` is paired with `Stream::Stdout`.** If this were `eprintln!`, it would need to be paired with `Stream::Stderr`.
62+
63+
[the immediate pattern]: #the-immediate-pattern

0 commit comments

Comments
 (0)