Skip to content

Commit

Permalink
Merge pull request #795 from teozkr/bugfix/absolute-result
Browse files Browse the repository at this point in the history
Use absolute path to Result in derives
  • Loading branch information
nightkr authored Jan 26, 2022
2 parents 3d5f90d + 85858ef commit 18b5316
Showing 1 changed file with 8 additions and 1 deletion.
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

0 comments on commit 18b5316

Please sign in to comment.