Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ObjectRef::from as alias for ::from_obj #1598

Merged
merged 1 commit into from
Oct 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
}

#[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
Loading