Revert "tweak: use format_args for efficiency"
This reverts commit 61486fae7d.
We convert the color inside the function, so we can't reference it outside the function
error[E0515]: cannot return value referencing local variable `c_u8`
--> /home/ahann/Documents/GitHub/libcosmic/cosmic-theme/src/output/qt_output.rs:340:5
|
340 | format_args!("{},{},{}", c_u8.red, c_u8.green, c_u8.blue)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^----^^^^^^
| | |
| | `c_u8` is borrowed here
| returns a value referencing data owned by the current function
|
This commit is contained in:
parent
371cd1f542
commit
434a7374a8
1 changed files with 8 additions and 9 deletions
|
|
@ -1,7 +1,6 @@
|
||||||
use crate::Theme;
|
use crate::Theme;
|
||||||
use palette::{Mix, Srgba, blend::Compose};
|
use palette::{Mix, Srgba, blend::Compose};
|
||||||
use std::{
|
use std::{
|
||||||
fmt,
|
|
||||||
fs::{self, File},
|
fs::{self, File},
|
||||||
io::{self, Write},
|
io::{self, Write},
|
||||||
path::Path,
|
path::Path,
|
||||||
|
|
@ -325,13 +324,13 @@ contrast=4
|
||||||
|
|
||||||
/// Formats a color in the form `r,g,b` e.g. `255,255,255`.
|
/// Formats a color in the form `r,g,b` e.g. `255,255,255`.
|
||||||
/// If the color has transparency, it is mixed with bg first.
|
/// If the color has transparency, it is mixed with bg first.
|
||||||
fn to_rgb(c: Srgba, bg: Srgba) -> fmt::Arguments<'static> {
|
fn to_rgb(c: Srgba, bg: Srgba) -> String {
|
||||||
let c_u8: Srgba<u8> = c.over(bg).into_format();
|
let c_u8: Srgba<u8> = c.over(bg).into_format();
|
||||||
format_args!("{},{},{}", c_u8.red, c_u8.green, c_u8.blue)
|
format!("{},{},{}", c_u8.red, c_u8.green, c_u8.blue)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn format_ini_color_effects(color_effects: &IniColorEffects, bg: Srgba) -> fmt::Arguments<'_> {
|
fn format_ini_color_effects(color_effects: &IniColorEffects, bg: Srgba) -> String {
|
||||||
format_args!(
|
format!(
|
||||||
r#"Color={}
|
r#"Color={}
|
||||||
ColorAmount={}
|
ColorAmount={}
|
||||||
ColorEffect={}
|
ColorEffect={}
|
||||||
|
|
@ -349,8 +348,8 @@ IntensityEffect={}"#,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn format_ini_colors(colors: &IniColors, bg: Srgba) -> fmt::Arguments<'_> {
|
fn format_ini_colors(colors: &IniColors, bg: Srgba) -> String {
|
||||||
format_args!(
|
format!(
|
||||||
r#"BackgroundAlternate={}
|
r#"BackgroundAlternate={}
|
||||||
BackgroundNormal={}
|
BackgroundNormal={}
|
||||||
DecorationFocus={}
|
DecorationFocus={}
|
||||||
|
|
@ -379,12 +378,12 @@ ForegroundVisited={}"#,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sets the colors for the titlebars of active and inactive windows.
|
/// Sets the colors for the titlebars of active and inactive windows.
|
||||||
fn format_ini_wm_colors(view_colors: &IniColors, is_dark: bool) -> fmt::Arguments<'_> {
|
fn format_ini_wm_colors(view_colors: &IniColors, is_dark: bool) -> String {
|
||||||
let bg = view_colors.background_normal;
|
let bg = view_colors.background_normal;
|
||||||
let fg = view_colors.foreground_active;
|
let fg = view_colors.foreground_active;
|
||||||
let blend = if is_dark { fg } else { bg };
|
let blend = if is_dark { fg } else { bg };
|
||||||
|
|
||||||
format_args!(
|
format!(
|
||||||
r#"activeBackground={}
|
r#"activeBackground={}
|
||||||
activeBlend={}
|
activeBlend={}
|
||||||
activeForeground={}
|
activeForeground={}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue