Skip to content

Commit

Permalink
Merge pull request #35 from Mart-Bogdan/intelij-rust-types
Browse files Browse the repository at this point in the history
Added type coercion to &str for concatcp! macro
  • Loading branch information
rodrimati1992 authored May 4, 2022
2 parents d8a1917 + 73baa86 commit f883cc0
Showing 1 changed file with 34 additions and 25 deletions.
59 changes: 34 additions & 25 deletions const_format/src/macros/fmt_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,14 @@
#[macro_export]
macro_rules! concatcp {
()=>{""};
($($arg: expr),* $(,)?)=>({
use $crate::__cf_osRcTFl4A;
$crate::pmr::__concatcp_impl!{
$( ( $arg ), )*
}
});
($($arg: expr),* $(,)?)=>(
{
use $crate::__cf_osRcTFl4A;
$crate::pmr::__concatcp_impl!{
$( ( $arg ), )*
}
} as &'static $crate::pmr::str
);
}

#[doc(hidden)]
Expand Down Expand Up @@ -256,14 +258,16 @@ 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,)+)?
)
});
($format_string:expr $( $(, $expr:expr )+ )? $(,)? ) => (
{
use $crate::__cf_osRcTFl4A;

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

////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -325,11 +329,14 @@ macro_rules! formatcp {
#[macro_export]
macro_rules! concatc {
()=>{""};
($($anything:tt)*)=>({
use $crate::__cf_osRcTFl4A;
($($anything:tt)*)=>(
{
use $crate::__cf_osRcTFl4A;

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

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

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

/// Writes some formatted standard library and/or user-defined types into a buffer.
Expand Down

0 comments on commit f883cc0

Please sign in to comment.