Skip to content

Commit

Permalink
Mark some more functions as const fn (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
waywardmonkeys authored Dec 17, 2024
1 parent 05ec40d commit 1bd9e5c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/blend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ impl BlendMode {
/// Creates a new blend mode from color mixing and layer composition
/// functions.
#[must_use]
pub fn new(mix: Mix, compose: Compose) -> Self {
pub const fn new(mix: Mix, compose: Compose) -> Self {
Self { mix, compose }
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/gradient.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ impl BitEq for ColorStop {
impl ColorStop {
/// Returns the color stop with the alpha component set to `alpha`.
#[must_use]
pub fn with_alpha(self, alpha: f32) -> Self {
pub const fn with_alpha(self, alpha: f32) -> Self {
Self {
offset: self.offset,
color: self.color.with_alpha(alpha),
Expand All @@ -60,7 +60,7 @@ impl ColorStop {
///
/// If any resulting alphas would overflow, these currently saturate (to opaque).
#[must_use]
pub fn multiply_alpha(self, alpha: f32) -> Self {
pub const fn multiply_alpha(self, alpha: f32) -> Self {
Self {
offset: self.offset,
color: self.color.multiply_alpha(alpha),
Expand Down Expand Up @@ -276,21 +276,21 @@ impl Gradient {

/// Builder method for setting the gradient extend mode.
#[must_use]
pub fn with_extend(mut self, mode: Extend) -> Self {
pub const fn with_extend(mut self, mode: Extend) -> Self {
self.extend = mode;
self
}

/// Builder method for setting the interpolation color space.
#[must_use]
pub fn with_interpolation_cs(mut self, interpolation_cs: ColorSpaceTag) -> Self {
pub const fn with_interpolation_cs(mut self, interpolation_cs: ColorSpaceTag) -> Self {
self.interpolation_cs = interpolation_cs;
self
}

/// Builder method for setting the hue direction when interpolating within a cylindrical color space.
#[must_use]
pub fn with_hue_direction(mut self, hue_direction: HueDirection) -> Self {
pub const fn with_hue_direction(mut self, hue_direction: HueDirection) -> Self {
self.hue_direction = hue_direction;
self
}
Expand Down

0 comments on commit 1bd9e5c

Please sign in to comment.