[−][src]Trait termcolor_output::WriteColorGuard
Extension trait for WriteColor
instances.
This trait is not intended for public use. Its only purpose is to allow us check if the
provided value implements WriteColor
in an ergonomic way, without consuming the value if
unnecessary, and it is used internally by the colored
macro.
You'll probably see this trait only in type errors, if the first argument to the macro appears to be of the wrong type.
Example
ⓘThis example deliberately fails to compile
use termcolor_output::colored; colored!(0u8, "This won't be written")?;
This example yields the following error:
error[E0599]: no method named `guard` found for type `u8` in the current scope
--> src/lib.rs:37:1
|
5 | colored!(0u8, "This won't be written")?;
| ^^^
|
= note: the method `guard` exists but the following trait bounds were not satisfied:
`u8 : termcolor_output::WriteColorGuard`
This trait is implemented on everything that implements WriteColor
and sealed, so that it
can't be implemented elsewhere.