mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-15 14:18:04 +08:00
Apply lints and cleanup to Rust code
This commit is contained in:
@@ -150,7 +150,7 @@ impl Bezier {
|
||||
|
||||
/// Appends to the `svg` mutable string with an SVG shape representation of the handle lines.
|
||||
pub fn handle_lines_to_svg(&self, svg: &mut String, attributes: String) {
|
||||
let _ = write!(svg, r#"<path d="{}" {}/>"#, self.svg_handle_line_argument().unwrap_or_else(|| "".to_string()), attributes);
|
||||
let _ = write!(svg, r#"<path d="{}" {}/>"#, self.svg_handle_line_argument().unwrap_or_default(), attributes);
|
||||
}
|
||||
|
||||
/// Appends to the `svg` mutable string with an SVG shape representation of the anchors.
|
||||
|
||||
@@ -16,7 +16,7 @@ pub struct ProjectionOptions {
|
||||
|
||||
impl Default for ProjectionOptions {
|
||||
fn default() -> Self {
|
||||
ProjectionOptions {
|
||||
Self {
|
||||
lut_size: 20,
|
||||
convergence_epsilon: 1e-4,
|
||||
convergence_limit: 3,
|
||||
@@ -56,7 +56,7 @@ pub struct ArcsOptions {
|
||||
|
||||
impl Default for ArcsOptions {
|
||||
fn default() -> Self {
|
||||
ArcsOptions {
|
||||
Self {
|
||||
strategy: ArcStrategy::Automatic,
|
||||
error: 0.5,
|
||||
max_iterations: 100,
|
||||
@@ -85,7 +85,7 @@ impl Debug for CircleArc {
|
||||
|
||||
impl Default for CircleArc {
|
||||
fn default() -> Self {
|
||||
CircleArc {
|
||||
Self {
|
||||
center: DVec2::ZERO,
|
||||
radius: 0.,
|
||||
start_angle: 0.,
|
||||
|
||||
@@ -61,8 +61,8 @@ impl Bezier {
|
||||
};
|
||||
}
|
||||
// Depending on the order of `t1` and `t2`, determine which half of the split we need to keep
|
||||
let t1_split_side = if t1 <= t2 { 1 } else { 0 };
|
||||
let t2_split_side = if t1 <= t2 { 0 } else { 1 };
|
||||
let t1_split_side = usize::from(t1 <= t2);
|
||||
let t2_split_side = usize::from(t1 > t2);
|
||||
let bezier_starting_at_t1 = self.split(t1)[t1_split_side];
|
||||
// Adjust the ratio `t2` to its corresponding value on the new curve that was split on `t1`
|
||||
let adjusted_t2 = if t1 < t2 || t1 == 0. {
|
||||
|
||||
@@ -58,7 +58,7 @@ mod tests {
|
||||
let handle2 = DVec2::new(40., 30.);
|
||||
let handle3 = DVec2::new(10., 10.);
|
||||
|
||||
return Subpath::new(
|
||||
Subpath::new(
|
||||
vec![
|
||||
ManipulatorGroup {
|
||||
anchor: start,
|
||||
@@ -82,7 +82,7 @@ mod tests {
|
||||
},
|
||||
],
|
||||
false,
|
||||
);
|
||||
)
|
||||
}
|
||||
|
||||
fn set_up_closed_subpath() -> Subpath {
|
||||
|
||||
@@ -45,7 +45,7 @@ pub fn get_closest_point_in_lut(lut: &[DVec2], point: DVec2) -> (usize, f64) {
|
||||
lut.iter()
|
||||
.enumerate()
|
||||
.map(|(i, p)| (i, point.distance_squared(*p)))
|
||||
.min_by(|x, y| (&(x.1)).partial_cmp(&(y.1)).unwrap())
|
||||
.min_by(|x, y| (x.1).partial_cmp(&(y.1)).unwrap())
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user