summaryrefslogtreecommitdiff
path: root/src/geom
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-01-05 14:49:14 +0100
committerLaurenz <laurmaedje@gmail.com>2022-01-05 15:06:42 +0100
commitf7e8624b4cf31744d600167dd7f3a9d9d1626014 (patch)
tree0941c8db497befc47a666d3d1384db4ab9fc5133 /src/geom
parent4c81a5d43eabd959dbb500a8076f99f21bd037bd (diff)
Refactor
Diffstat (limited to 'src/geom')
-rw-r--r--src/geom/spec.rs17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/geom/spec.rs b/src/geom/spec.rs
index 40d7386b..cf75f42d 100644
--- a/src/geom/spec.rs
+++ b/src/geom/spec.rs
@@ -85,10 +85,19 @@ impl<T> Spec<T> {
}
}
-impl<T> Spec<T>
-where
- T: Ord,
-{
+impl<T: Default> Spec<T> {
+ /// Create a new instance with y set to its default value.
+ pub fn with_x(x: T) -> Self {
+ Self { x, y: T::default() }
+ }
+
+ /// Create a new instance with x set to its default value.
+ pub fn with_y(y: T) -> Self {
+ Self { x: T::default(), y }
+ }
+}
+
+impl<T: Ord> Spec<T> {
/// The component-wise minimum of this and another instance.
pub fn min(self, other: Self) -> Self {
Self {