mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-17 15:28:04 +08:00
A few minor lints and docs (#1436)
* A few minor lints and docs * Added required packages to compile on Debian-style linux * Inlined some format args, and removed some `&` in args (they cause about 6% slowdown that compiler cannot inline) * a few spelling mistakes * fix fmt
This commit is contained in:
@@ -3,7 +3,7 @@ use crate::uuid::{generate_uuid, ManipulatorGroupId};
|
||||
use crate::{vector::VectorData, Artboard, Color, GraphicElementData, GraphicGroup};
|
||||
use base64::Engine;
|
||||
use bezier_rs::Subpath;
|
||||
use image::ImageEncoder;
|
||||
|
||||
pub use quad::Quad;
|
||||
|
||||
use glam::{DAffine2, DVec2};
|
||||
@@ -156,7 +156,7 @@ pub fn format_transform_matrix(transform: DAffine2) -> String {
|
||||
let mut result = "matrix(".to_string();
|
||||
let cols = transform.to_cols_array();
|
||||
for (index, item) in cols.iter().enumerate() {
|
||||
write!(result, "{}", item).unwrap();
|
||||
write!(result, "{item}").unwrap();
|
||||
if index != cols.len() - 1 {
|
||||
result.push_str(", ");
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ pub struct LogToConsoleNode;
|
||||
#[node_macro::node_fn(LogToConsoleNode)]
|
||||
fn log_to_console<T: core::fmt::Debug>(value: T) -> T {
|
||||
#[cfg(not(target_arch = "spirv"))]
|
||||
debug!("{:#?}", value);
|
||||
debug!("{value:#?}");
|
||||
value
|
||||
}
|
||||
|
||||
|
||||
@@ -190,13 +190,13 @@ impl Type {
|
||||
impl core::fmt::Debug for Type {
|
||||
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
||||
match self {
|
||||
Self::Generic(arg0) => write!(f, "Generic({})", arg0),
|
||||
Self::Generic(arg0) => write!(f, "Generic({arg0})"),
|
||||
#[cfg(feature = "type_id_logging")]
|
||||
Self::Concrete(arg0) => write!(f, "Concrete({}, {:?})", arg0.name, arg0.id),
|
||||
#[cfg(not(feature = "type_id_logging"))]
|
||||
Self::Concrete(arg0) => write!(f, "Concrete({})", arg0.name),
|
||||
Self::Fn(arg0, arg1) => write!(f, "({:?} -> {:?})", arg0, arg1),
|
||||
Self::Future(arg0) => write!(f, "Future({:?})", arg0),
|
||||
Self::Fn(arg0, arg1) => write!(f, "({arg0:?} -> {arg1:?})"),
|
||||
Self::Future(arg0) => write!(f, "Future({arg0:?})"),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -204,10 +204,10 @@ impl core::fmt::Debug for Type {
|
||||
impl std::fmt::Display for Type {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
Type::Generic(name) => write!(f, "{}", name),
|
||||
Type::Generic(name) => write!(f, "{name}"),
|
||||
Type::Concrete(ty) => write!(f, "{}", ty.name),
|
||||
Type::Fn(input, output) => write!(f, "({} -> {})", input, output),
|
||||
Type::Future(ty) => write!(f, "Future<{}>", ty),
|
||||
Type::Fn(input, output) => write!(f, "({input} -> {output})"),
|
||||
Type::Future(ty) => write!(f, "Future<{ty}>"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ const OPACITY_PRECISION: usize = 3;
|
||||
|
||||
fn format_opacity(name: &str, opacity: f32) -> String {
|
||||
if (opacity - 1.).abs() > 10_f32.powi(-(OPACITY_PRECISION as i32)) {
|
||||
format!(r#" {}-opacity="{:.precision$}""#, name, opacity, precision = OPACITY_PRECISION)
|
||||
format!(r#" {name}-opacity="{opacity:.OPACITY_PRECISION$}""#)
|
||||
} else {
|
||||
String::new()
|
||||
}
|
||||
@@ -187,7 +187,7 @@ impl Fill {
|
||||
Self::Solid(color) => format!(r##" fill="#{}"{}"##, color.rgb_hex(), format_opacity("fill", color.a())),
|
||||
Self::Gradient(gradient) => {
|
||||
let gradient_id = gradient.render_defs(svg_defs, multiplied_transform, bounds, transformed_bounds);
|
||||
format!(r##" fill="url('#{}')""##, gradient_id)
|
||||
format!(r##" fill="url('#{gradient_id}')""##)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -533,7 +533,7 @@ impl PathStyle {
|
||||
(_, None) => String::new(),
|
||||
};
|
||||
|
||||
format!("{}{}", fill_attribute, stroke_attribute)
|
||||
format!("{fill_attribute}{stroke_attribute}")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -392,7 +392,7 @@ impl Subpath {
|
||||
(true, true, true) => 'C',
|
||||
(false, false, true) => 'L',
|
||||
(_, false, false) => 'Z',
|
||||
_ => panic!("Invalid shape {:#?}", self),
|
||||
_ => panic!("Invalid shape {self:#?}"),
|
||||
};
|
||||
|
||||
// Complete the last curve
|
||||
@@ -567,7 +567,7 @@ impl From<&Subpath> for BezPath {
|
||||
}
|
||||
}
|
||||
[None, None, None] => (PathEl::ClosePath, true),
|
||||
_ => panic!("Invalid path element {:#?}", subpath),
|
||||
_ => panic!("Invalid path element {subpath:#?}"),
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user