Skip to content

Commit

Permalink
Move Self: Sized bound from Shape to methods.
Browse files Browse the repository at this point in the history
The `Shape` trait overall doesn't need the `Self: Sized` bound
only 2 methods do, so move the bound there.
  • Loading branch information
waywardmonkeys committed Mar 7, 2024
1 parent 389c71b commit 3ea8f6b
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/shape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use crate::{segments, BezPath, Circle, Line, PathEl, Point, Rect, RoundedRect, S
/// [`area`]: Shape::area
/// [`bounding_box`]: Shape::bounding_box
/// [`winding`]: Shape::winding
pub trait Shape: Sized {
pub trait Shape {
/// The iterator returned by the [`path_elements`] method.
///
/// [`path_elements`]: Shape::path_elements
Expand Down Expand Up @@ -73,6 +73,7 @@ pub trait Shape: Sized {
fn to_bez_path(&self, tolerance: f64) -> Self::PathElementsIter<'_> {
self.path_elements(tolerance)
}

/// Convert into a Bézier path.
///
/// This allocates in the general case, but is zero-cost if the
Expand All @@ -81,13 +82,19 @@ pub trait Shape: Sized {
/// The `tolerance` parameter is the same as for [`path_elements()`].
///
/// [`path_elements()`]: Shape::path_elements
fn into_path(self, tolerance: f64) -> BezPath {
fn into_path(self, tolerance: f64) -> BezPath
where
Self: Sized,
{
self.to_path(tolerance)
}

#[deprecated(since = "0.7.0", note = "Use into_path instead")]
#[doc(hidden)]
fn into_bez_path(self, tolerance: f64) -> BezPath {
fn into_bez_path(self, tolerance: f64) -> BezPath
where
Self: Sized,
{
self.into_path(tolerance)
}

Expand Down

0 comments on commit 3ea8f6b

Please sign in to comment.