From 1ed864ab5e152ea6a0690bcc01da8a4b83965cce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Natalie=20Klestrup=20R=C3=B6ijezon?= Date: Wed, 9 Oct 2024 12:46:29 +0200 Subject: [PATCH] Add ObjectRef::from as alias for ::from_obj MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Natalie Klestrup Röijezon --- kube-runtime/src/reflector/object_ref.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/kube-runtime/src/reflector/object_ref.rs b/kube-runtime/src/reflector/object_ref.rs index a4db8473d..9cfc4e028 100644 --- a/kube-runtime/src/reflector/object_ref.rs +++ b/kube-runtime/src/reflector/object_ref.rs @@ -168,14 +168,20 @@ where } #[must_use] - pub fn from_obj(obj: &K) -> Self - where - K: Lookup, - { + pub fn from_obj(obj: &K) -> Self { obj.to_object_ref(Default::default()) } } +impl From<&K> for ObjectRef +where + K::DynamicType: Default, +{ + fn from(obj: &K) -> Self { + Self::from_obj(obj) + } +} + impl ObjectRef { #[must_use] pub fn new_with(name: &str, dyntype: K::DynamicType) -> Self {