Split parse macros
Done in preparation for enabling no-alloc builds. Split the macro calls to handle `str` separately from `alloc` types.
This commit is contained in:
parent
515c0f584a
commit
88f6621e30
|
@ -2,8 +2,6 @@
|
|||
|
||||
//! Provides [`Height`] and [`Time`] types used by the `rust-bitcoin` `absolute::LockTime` type.
|
||||
|
||||
#[cfg(feature = "alloc")]
|
||||
use alloc::{boxed::Box, string::String};
|
||||
use core::fmt;
|
||||
|
||||
use internals::error::InputString;
|
||||
|
|
|
@ -107,10 +107,9 @@ macro_rules! impl_tryfrom_str_from_int_infallible {
|
|||
#[macro_export]
|
||||
macro_rules! impl_parse_str_from_int_infallible {
|
||||
($to:ident, $inner:ident, $fn:ident) => {
|
||||
#[cfg(all(feature = "alloc", not(feature = "std")))]
|
||||
$crate::impl_tryfrom_str_from_int_infallible!(&str, $to, $inner, $fn; alloc::string::String, $to, $inner, $fn; alloc::boxed::Box<str>, $to, $inner, $fn);
|
||||
#[cfg(feature = "std")]
|
||||
$crate::impl_tryfrom_str_from_int_infallible!(&str, $to, $inner, $fn; std::string::String, $to, $inner, $fn; std::boxed::Box<str>, $to, $inner, $fn);
|
||||
$crate::impl_tryfrom_str_from_int_infallible!(&str, $to, $inner, $fn);
|
||||
#[cfg(feature = "alloc")]
|
||||
$crate::impl_tryfrom_str_from_int_infallible!(alloc::string::String, $to, $inner, $fn; alloc::boxed::Box<str>, $to, $inner, $fn);
|
||||
|
||||
impl core::str::FromStr for $to {
|
||||
type Err = $crate::parse::ParseIntError;
|
||||
|
@ -143,7 +142,9 @@ macro_rules! impl_tryfrom_str {
|
|||
#[macro_export]
|
||||
macro_rules! impl_parse_str {
|
||||
($to:ty, $err:ty, $inner_fn:expr) => {
|
||||
$crate::impl_tryfrom_str!(&str, $to, $err, $inner_fn; String, $to, $err, $inner_fn; Box<str>, $to, $err, $inner_fn);
|
||||
$crate::impl_tryfrom_str!(&str, $to, $err, $inner_fn);
|
||||
#[cfg(feature = "alloc")]
|
||||
$crate::impl_tryfrom_str!(alloc::string::String, $to, $err, $inner_fn; alloc::boxed::Box<str>, $to, $err, $inner_fn);
|
||||
|
||||
impl core::str::FromStr for $to {
|
||||
type Err = $err;
|
||||
|
|
Loading…
Reference in New Issue