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

Disable Serde's default-features #905

Merged
merged 3 commits into from Apr 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Expand Up @@ -41,7 +41,7 @@ core2 = { version = "0.3.0", optional = true, default-features = false }

base64-compat = { version = "1.0.0", optional = true }
bitcoinconsensus = { version = "0.19.0-3", optional = true }
serde = { version = "1", features = [ "derive" ], optional = true }
serde = { version = "1", default-features = false, features = [ "derive", "alloc" ], optional = true }
hashbrown = { version = "0.8", optional = true }

[dev-dependencies]
ass3rt marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
21 changes: 7 additions & 14 deletions src/blockdata/script.rs
Expand Up @@ -1024,20 +1024,6 @@ impl<'de> serde::Deserialize<'de> for Script {
let v = Vec::from_hex(v).map_err(E::custom)?;
Ok(Script::from(v))
}

fn visit_borrowed_str<E>(self, v: &'de str) -> Result<Self::Value, E>
where
E: serde::de::Error,
{
self.visit_str(v)
}

fn visit_string<E>(self, v: String) -> Result<Self::Value, E>
where
E: serde::de::Error,
{
self.visit_str(&v)
}
}
deserializer.deserialize_str(Visitor)
} else {
Expand All @@ -1056,6 +1042,13 @@ impl<'de> serde::Deserialize<'de> for Script {
{
Ok(Script::from(v.to_vec()))
}

fn visit_byte_buf<E>(self, v: Vec<u8>) -> Result<Self::Value, E>
where
E: serde::de::Error,
{
Ok(Script::from(v))
}
}
deserializer.deserialize_bytes(BytesVisitor)
}
Expand Down
42 changes: 0 additions & 42 deletions src/internal_macros.rs
Expand Up @@ -152,20 +152,6 @@ macro_rules! serde_string_impl {
{
$name::from_str(v).map_err(E::custom)
}

fn visit_borrowed_str<E>(self, v: &'de str) -> Result<Self::Value, E>
where
E: $crate::serde::de::Error,
{
self.visit_str(v)
}

fn visit_string<E>(self, v: $crate::prelude::String) -> Result<Self::Value, E>
where
E: $crate::serde::de::Error,
{
self.visit_str(&v)
}
}

deserializer.deserialize_str(Visitor)
Expand Down Expand Up @@ -215,19 +201,6 @@ macro_rules! serde_struct_human_string_impl {
$name::from_str(v).map_err(E::custom)
}

fn visit_borrowed_str<E>(self, v: &'de str) -> Result<Self::Value, E>
where
E: $crate::serde::de::Error,
{
self.visit_str(v)
}

fn visit_string<E>(self, v: $crate::prelude::String) -> Result<Self::Value, E>
where
E: $crate::serde::de::Error,
{
self.visit_str(&v)
}
}

deserializer.deserialize_str(Visitor)
Expand Down Expand Up @@ -573,21 +546,6 @@ macro_rules! user_enum {
Err(E::unknown_variant(v, FIELDS))
}
}

fn visit_borrowed_str<E>(self, v: &'de str) -> Result<Self::Value, E>
where
E: $crate::serde::de::Error,
{
self.visit_str(v)
}

fn visit_string<E>(self, v: $crate::prelude::String) -> Result<Self::Value, E>
where
E: $crate::serde::de::Error,
{
self.visit_str(&v)
}

}

deserializer.deserialize_str(Visitor)
Expand Down