Make serde usable in no_std

This commit is contained in:
Steven Roose 2023-02-27 21:16:15 +00:00
parent e7155f153d
commit ca53ee34a8
No known key found for this signature in database
GPG Key ID: 2F2A88D7F8D68E87
3 changed files with 6 additions and 3 deletions

View File

@ -45,7 +45,7 @@ rand_core = "0.4.0"
unicode-normalization = { version = "=0.1.9", optional = true }
rand = { version = "0.6.0", optional = true }
serde = { version = "1.0", default-features = false, optional = true }
serde = { version = "1.0", default-features = false, features = [ "alloc" ], optional = true }
# Enabling this feature raises the MSRV to 1.51
zeroize = {version = "1.5", features = ["zeroize_derive"], optional = true}

View File

@ -8,8 +8,9 @@ macro_rules! serde_string_impl {
where
D: $crate::serde::de::Deserializer<'de>,
{
use std::fmt::{self, Formatter};
use std::str::FromStr;
use core::fmt::{self, Formatter};
use core::str::FromStr;
use alloc::string::String;
struct Visitor;
impl<'de> $crate::serde::de::Visitor<'de> for Visitor {

View File

@ -28,6 +28,8 @@
#[cfg(any(test, feature = "std"))]
pub extern crate core;
extern crate alloc;
extern crate bitcoin_hashes;
extern crate rand_core;