我正在尝试将 args 打印到以下函数:
pub async fn loop_until_hit_rate_limit<'a, T, Fut>(
object_arr: &'a [T],
settings: &'a Settings,
pool: &'a PgPool,
f: impl Fn(&'a Settings, &'a PgPool, &'a T) -> Fut + Copy,
rate_limit: usize,
) where
Fut: Future<Output = anyhow::Result<()>>,
{
// do stuff
println!("args were: {}, {}, {}, {}, {}", object_arr, settings, pool, f, rate_limit) // <--- how do I make this work?
}
Run Code Online (Sandbox Code Playgroud)
天真的方法失败并出现以下错误(对于 {}):
^ `impl Fn(&'a Settings, &'a PgPool, &'a T) -> Fut + Copy` cannot be formatted …Run Code Online (Sandbox Code Playgroud) Rust 有没有办法获取“调用”函数名称或宏内的任何其他上下文信息?
例子:
#[macro_export]
macro_rules! somemacro {
( $x:expr ) => {
{
// access function name (etc..) that called this macro
}
};
}
Run Code Online (Sandbox Code Playgroud)