From 4ae391e9fd9c581cc2982cf747107a292a571bae Mon Sep 17 00:00:00 2001 From: Quaternions Date: Wed, 28 Aug 2024 09:06:16 -0700 Subject: [PATCH] trait constructor doesn't work because trait bounds (and is also bad) --- deferred_division/src/ratio.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/deferred_division/src/ratio.rs b/deferred_division/src/ratio.rs index a6bd02d..6ae0ad2 100644 --- a/deferred_division/src/ratio.rs +++ b/deferred_division/src/ratio.rs @@ -3,8 +3,8 @@ pub struct Ratio{ pub(crate)num:Num, pub(crate)den:Den, } -//this trait is like a constructor for Ratio -pub trait DeferredDiv{ - type Output; - fn deferred_div(self,rhs:Rhs)->Self::Output; +impl Ratio{ + pub const fn new(num:Num,den:Den)->Self{ + Self{num,den} + } }