Skip to content

Commit 8966ec7

Browse files
committed
Merge rust-bitcoin/rust-bitcoin#905: Disable Serde's default-features
76fcf81 Override default visit_byte_buf on Script (ass3rt) add100c Removed reimplementations of default methods (ass3rt) 7db03f2 Disable Serde's default-features (ass3rt) Pull request description: With this patch, existing users of the `use-serde` feature will no longer be compiling with `serde/std` enabled, but this allows dependent projects to import serde and enable `serde/alloc` as required by some no-std targets. ACKs for top commit: Kixunil: ACK 76fcf81 tcharding: ACK 76fcf81 apoelstra: ACK 76fcf81 Tree-SHA512: 5748e64e1f91f19dbfbf32bead6e6d759e448e92ed0dab731b3059f6b37bd811fad6654edc8fbd113e3be17fefaf9fc4912145d6b61484ced0517712361ecfdc
2 parents aef788b + 2a927d4 commit 8966ec7

File tree

3 files changed

+8
-57
lines changed

3 files changed

+8
-57
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ core2 = { version = "0.3.0", optional = true, default-features = false }
4141

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

4747
[dev-dependencies]

src/blockdata/script.rs

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,20 +1024,6 @@ impl<'de> serde::Deserialize<'de> for Script {
10241024
let v = Vec::from_hex(v).map_err(E::custom)?;
10251025
Ok(Script::from(v))
10261026
}
1027-
1028-
fn visit_borrowed_str<E>(self, v: &'de str) -> Result<Self::Value, E>
1029-
where
1030-
E: serde::de::Error,
1031-
{
1032-
self.visit_str(v)
1033-
}
1034-
1035-
fn visit_string<E>(self, v: String) -> Result<Self::Value, E>
1036-
where
1037-
E: serde::de::Error,
1038-
{
1039-
self.visit_str(&v)
1040-
}
10411027
}
10421028
deserializer.deserialize_str(Visitor)
10431029
} else {
@@ -1056,6 +1042,13 @@ impl<'de> serde::Deserialize<'de> for Script {
10561042
{
10571043
Ok(Script::from(v.to_vec()))
10581044
}
1045+
1046+
fn visit_byte_buf<E>(self, v: Vec<u8>) -> Result<Self::Value, E>
1047+
where
1048+
E: serde::de::Error,
1049+
{
1050+
Ok(Script::from(v))
1051+
}
10591052
}
10601053
deserializer.deserialize_bytes(BytesVisitor)
10611054
}

src/internal_macros.rs

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -152,20 +152,6 @@ macro_rules! serde_string_impl {
152152
{
153153
$name::from_str(v).map_err(E::custom)
154154
}
155-
156-
fn visit_borrowed_str<E>(self, v: &'de str) -> Result<Self::Value, E>
157-
where
158-
E: $crate::serde::de::Error,
159-
{
160-
self.visit_str(v)
161-
}
162-
163-
fn visit_string<E>(self, v: $crate::prelude::String) -> Result<Self::Value, E>
164-
where
165-
E: $crate::serde::de::Error,
166-
{
167-
self.visit_str(&v)
168-
}
169155
}
170156

171157
deserializer.deserialize_str(Visitor)
@@ -215,19 +201,6 @@ macro_rules! serde_struct_human_string_impl {
215201
$name::from_str(v).map_err(E::custom)
216202
}
217203

218-
fn visit_borrowed_str<E>(self, v: &'de str) -> Result<Self::Value, E>
219-
where
220-
E: $crate::serde::de::Error,
221-
{
222-
self.visit_str(v)
223-
}
224-
225-
fn visit_string<E>(self, v: $crate::prelude::String) -> Result<Self::Value, E>
226-
where
227-
E: $crate::serde::de::Error,
228-
{
229-
self.visit_str(&v)
230-
}
231204
}
232205

233206
deserializer.deserialize_str(Visitor)
@@ -573,21 +546,6 @@ macro_rules! user_enum {
573546
Err(E::unknown_variant(v, FIELDS))
574547
}
575548
}
576-
577-
fn visit_borrowed_str<E>(self, v: &'de str) -> Result<Self::Value, E>
578-
where
579-
E: $crate::serde::de::Error,
580-
{
581-
self.visit_str(v)
582-
}
583-
584-
fn visit_string<E>(self, v: $crate::prelude::String) -> Result<Self::Value, E>
585-
where
586-
E: $crate::serde::de::Error,
587-
{
588-
self.visit_str(&v)
589-
}
590-
591549
}
592550

593551
deserializer.deserialize_str(Visitor)

0 commit comments

Comments
 (0)