You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
use ansi_rgb::{Background,Foreground, red, green };fnmain(){let foo = "Hello, world!".fg(green()).bg(red());println!("{}", foo);}
Output:
error[E0716]: temporary value dropped while borrowed
--> src\main.rs:4:15
|
4 | let foo = "Hello, world!".fg(green()).bg(red());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - temporary value is freed at the end of this statement
| |
| creates a temporary which is freed while still in use
5 | println!("{}", foo);
| --- borrow later used here
|
= note: consider using a `let` binding to create a longer lived value
The text was updated successfully, but these errors were encountered:
Maybe implement Foreground and Background for T instead of &T. I think it will most often be used on &str which is Copy already, so it doesnt get moved.
Output:
The text was updated successfully, but these errors were encountered: