Skip to content

Commit

Permalink
Merge pull request #37 from rodrimati1992/0_2_24
Browse files Browse the repository at this point in the history
0.2.24, bugfix patch release
  • Loading branch information
rodrimati1992 authored May 28, 2022
2 parents 75684ce + 978e9ac commit b30eac3
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 12 deletions.
2 changes: 1 addition & 1 deletion const_format/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "const_format"
version = "0.2.23"
version = "0.2.24"
authors = ["rodrimati1992 <rodrimatt1985@gmail.com>"]
edition = "2018"
license = "Zlib"
Expand Down
16 changes: 8 additions & 8 deletions const_format/src/macros/fmt_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@
macro_rules! concatcp {
()=>{""};
($($arg: expr),* $(,)?)=>(
{
({
use $crate::__cf_osRcTFl4A;
$crate::pmr::__concatcp_impl!{
$( ( $arg ), )*
}
} as &'static $crate::pmr::str
} as &'static $crate::pmr::str)
);
}

Expand Down Expand Up @@ -259,14 +259,14 @@ macro_rules! __concatcp_inner {
#[macro_export]
macro_rules! formatcp {
($format_string:expr $( $(, $expr:expr )+ )? $(,)? ) => (
{
({
use $crate::__cf_osRcTFl4A;

$crate::pmr::__formatcp_impl!(
($format_string)
$(, $($expr,)+)?
)
} as &'static $crate::pmr::str
} as &'static $crate::pmr::str)
);
}

Expand Down Expand Up @@ -330,12 +330,12 @@ macro_rules! formatcp {
macro_rules! concatc {
()=>{""};
($($anything:tt)*)=>(
{
({
use $crate::__cf_osRcTFl4A;

$crate::__concatc_expr!(($($anything)*) ($($anything)*))
as &'static $crate::pmr::str
}
})
)
}

Expand Down Expand Up @@ -500,14 +500,14 @@ macro_rules! __concatc_inner {
#[cfg(feature = "fmt")]
macro_rules! formatc {
($format_string:expr $( $(, $expr:expr )+ )? $(,)? ) => (
{
({
use $crate::__cf_osRcTFl4A;

$crate::pmr::__formatc_impl!{
($format_string)
$(, $($expr,)+)?
}
} as &'static $crate::pmr::str
} as &'static $crate::pmr::str)
);
}

Expand Down
6 changes: 6 additions & 0 deletions const_format/src/test_utils.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
#![allow(missing_docs)]

#[doc(hidden)]
#[macro_export]
macro_rules! __identity {
($($tt:tt)*) => {$($tt)*};
}

#[doc(hidden)]
#[macro_export]
macro_rules! __declare_rng_ext {
Expand Down
63 changes: 61 additions & 2 deletions const_format/tests/misc_tests/shared_cp_macro_tests.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use cfmt_b::{concatcp, formatcp};
use cfmt_b::{__identity, concatcp, formatcp};

#[cfg(feature = "fmt")]
use cfmt_b::concatc;
use cfmt_b::{concatc, formatc};

use arrayvec::ArrayString;

Expand Down Expand Up @@ -90,3 +90,62 @@ fn other_tests() {
assert_eq!(EMPTY, "");
}
}

// test that this error doesn't happen:
// https://github.com/rodrimati1992/const_format_crates/issues/36
#[test]
fn call_in_braced_macro() {
{
assert_eq!(
{
__identity! {concatcp!("a", "b")}
},
"ab"
);
{
__identity! {concatcp!("a", "b")}
};
__identity! {concatcp!("a", "b")};
}

#[cfg(feature = "fmt")]
{
assert_eq!(
{
__identity! {concatc!("a", "b")}
},
"ab"
);
{
__identity! {concatc!("a", "b")}
};
__identity! {concatc!("a", "b")};
}

{
assert_eq!(
{
__identity! {formatcp!("ab")}
},
"ab"
);
{
__identity! {formatcp!("ab")}
};
__identity! {formatcp!("ab")};
}

#[cfg(feature = "fmt")]
{
assert_eq!(
{
__identity! {formatc!("ab")}
},
"ab"
);
{
__identity! {formatc!("ab")}
};
__identity! {formatc!("ab")};
}
}
1 change: 0 additions & 1 deletion const_format/tests/misc_tests_modules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ mod misc_tests {
#[cfg(not(feature = "only_new_tests"))]
mod impl_fmt_macro_tests;

#[cfg(feature = "assertc")]
#[cfg(not(feature = "only_new_tests"))]
mod shared_cp_macro_tests;

Expand Down

0 comments on commit b30eac3

Please sign in to comment.