Skip to content

Commit

Permalink
Add ObjectRef::from as alias for ::from_obj
Browse files Browse the repository at this point in the history
Signed-off-by: Natalie Klestrup Röijezon <nat@nullable.se>
  • Loading branch information
nightkr committed Oct 9, 2024
1 parent 62f95cd commit 1ed864a
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions kube-runtime/src/reflector/object_ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<K: Lookup> From<&K> for ObjectRef<K>
where
K::DynamicType: Default,
{
fn from(obj: &K) -> Self {
Self::from_obj(obj)

Check warning on line 181 in kube-runtime/src/reflector/object_ref.rs

View check run for this annotation

Codecov / codecov/patch

kube-runtime/src/reflector/object_ref.rs#L180-L181

Added lines #L180 - L181 were not covered by tests
}
}

impl<K: Lookup> ObjectRef<K> {
#[must_use]
pub fn new_with(name: &str, dyntype: K::DynamicType) -> Self {
Expand Down

0 comments on commit 1ed864a

Please sign in to comment.