Skip to content

Commit

Permalink
remove use serde in macro
Browse files Browse the repository at this point in the history
  • Loading branch information
maxomatic458 committed Oct 12, 2024
1 parent 05615c3 commit 627f540
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions crates/valence_generated/build/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,6 @@ pub(crate) fn build() -> anyhow::Result<TokenStream> {
.collect::<TokenStream>();

Ok(quote! {
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use serde::de::{self, Unexpected};

/// Represents an item from the game
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Default)]
#[repr(u16)]
Expand All @@ -196,23 +193,23 @@ pub(crate) fn build() -> anyhow::Result<TokenStream> {
pub snack: bool,
}

impl Serialize for ItemKind {
impl serde::Serialize for ItemKind {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
S: serde::Serializer,
{
serializer.serialize_str(self.to_str())
}
}

impl<'de> Deserialize<'de> for ItemKind {
impl<'de> serde::Deserialize<'de> for ItemKind {
fn deserialize<D>(deserializer: D) -> Result<ItemKind, D::Error>
where
D: Deserializer<'de>,
D: serde::Deserializer<'de>,
{
let s: &str = Deserialize::deserialize(deserializer)?;
let s: &str = serde::Deserialize::deserialize(deserializer)?;
ItemKind::from_str(s).ok_or_else(|| {
de::Error::invalid_value(Unexpected::Str(s), &"the snake case item name, like \"white_wool\"")
serde::de::Error::invalid_value(serde::de::Unexpected::Str(s), &"the snake case item name, like \"white_wool\"")
})
}
}
Expand Down

0 comments on commit 627f540

Please sign in to comment.