From b8d9df44e4688848997cf972bf49bf3c13deb0da Mon Sep 17 00:00:00 2001 From: John Vandenberg Date: Thu, 18 Apr 2024 10:14:18 +0800 Subject: [PATCH] Clone ForeignKey val (#244) --- butane_core/src/fkey.rs | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/butane_core/src/fkey.rs b/butane_core/src/fkey.rs index fb779182..f8411b93 100644 --- a/butane_core/src/fkey.rs +++ b/butane_core/src/fkey.rs @@ -1,7 +1,6 @@ //! Implementation of foreign key relationships between models. #![deny(missing_docs)] use std::borrow::Cow; -use std::fmt::{Debug, Formatter}; #[cfg(feature = "fake")] use fake::{Dummy, Faker}; @@ -28,6 +27,7 @@ use crate::{ /// blog: ForeignKey, /// ... /// } +#[derive(Clone, Debug)] pub struct ForeignKey where T: DataObject, @@ -105,17 +105,6 @@ impl From<&T> for ForeignKey { Self::from_pk(obj.pk().clone()) } } -impl Clone for ForeignKey { - fn clone(&self) -> Self { - // Once specialization lands, it would be nice to clone val if - // it's clone-able. Then we wouldn't have to ensure the pk - self.ensure_valpk(); - ForeignKey { - val: OnceCell::new(), - valpk: self.valpk.clone(), - } - } -} impl AsPrimaryKey for ForeignKey where @@ -127,11 +116,6 @@ where } impl Eq for ForeignKey {} -impl Debug for ForeignKey { - fn fmt(&self, f: &mut Formatter) -> std::fmt::Result { - self.ensure_valpk().fmt(f) - } -} impl ToSql for ForeignKey where