Info
This post is auto-generated from RSS feed The Rust Programming Language Forum - Latest topics. Source: Type_name returns different value for local function for const and non-const variable
Hi,
Recently I've decided to migrate function_name!()
to const and I've discovered that depending on if variable is const or let I get different results from type_name
#![feature(const_type_name)]
const fn type_name_of<T>(_: &T) -> &'static str {
std::any::type_name::<T>()
}
fn main() {
const A: &str = {
fn f() {}
type_name_of(&f)
};
let b: &str = {
fn f() {}
type_name_of(&f)
};
println!("A: {}. B: {}", A, b)
}
A: playground::main::A::f. B: playground::main::f
Is it something expected or should I create a bug for it?
1 post - 1 participant
🏷️ Rust_feed