Skip to content

Commit

Permalink
Clone ForeignKey val (#244)
Browse files Browse the repository at this point in the history
  • Loading branch information
jayvdb authored Apr 18, 2024
1 parent 816bd62 commit b8d9df4
Showing 1 changed file with 1 addition and 17 deletions.
18 changes: 1 addition & 17 deletions butane_core/src/fkey.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand All @@ -28,6 +27,7 @@ use crate::{
/// blog: ForeignKey<Blog>,
/// ...
/// }
#[derive(Clone, Debug)]
pub struct ForeignKey<T>
where
T: DataObject,
Expand Down Expand Up @@ -105,17 +105,6 @@ impl<T: DataObject> From<&T> for ForeignKey<T> {
Self::from_pk(obj.pk().clone())
}
}
impl<T: DataObject> Clone for ForeignKey<T> {
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<T> AsPrimaryKey<T> for ForeignKey<T>
where
Expand All @@ -127,11 +116,6 @@ where
}

impl<T: DataObject> Eq for ForeignKey<T> {}
impl<T: DataObject> Debug for ForeignKey<T> {
fn fmt(&self, f: &mut Formatter) -> std::fmt::Result {
self.ensure_valpk().fmt(f)
}
}

impl<T> ToSql for ForeignKey<T>
where
Expand Down

0 comments on commit b8d9df4

Please sign in to comment.