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

Use absolute path to Result in derives #795

Merged
merged 1 commit into from
Jan 26, 2022
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
Use absolute path to Result in derives
Fixes #794

Signed-off-by: Teo Klestrup Röijezon <[email protected]>
  • Loading branch information
nightkr committed Jan 26, 2022
commit 85858ef3e450a95fb93cf9807cd44ac095893821
9 changes: 8 additions & 1 deletion kube-derive/src/custom_resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ struct Crates {
serde: Path,
#[darling(default = "Self::default_serde_json")]
serde_json: Path,
#[darling(default = "Self::default_std")]
std: Path,
}

// Default is required when the subattribute isn't mentioned at all
Expand Down Expand Up @@ -81,6 +83,10 @@ impl Crates {
fn default_serde_json() -> Path {
parse_quote! { ::serde_json }
}

fn default_std() -> Path {
parse_quote! { ::std }
}
}

fn default_apiext() -> String {
Expand Down Expand Up @@ -167,6 +173,7 @@ pub(crate) fn derive(input: proc_macro2::TokenStream) -> proc_macro2::TokenStrea
schemars,
serde,
serde_json,
std,
},
} = kube_attrs;

Expand Down Expand Up @@ -271,7 +278,7 @@ pub(crate) fn derive(input: proc_macro2::TokenStream) -> proc_macro2::TokenStrea
}
}
impl #serde::Serialize for #rootident {
fn serialize<S: #serde::Serializer>(&self, ser: S) -> Result<S::Ok, S::Error> {
fn serialize<S: #serde::Serializer>(&self, ser: S) -> #std::result::Result<S::Ok, S::Error> {
use #serde::ser::SerializeStruct;
let mut obj = ser.serialize_struct(#rootident_str, 4 + usize::from(#has_status_value))?;
obj.serialize_field("apiVersion", &<#rootident as #kube_core::Resource>::api_version(&()))?;
Expand Down