Is there a way to use a newly stabilized library feature when compiling with the latest compiler while still using the old way with older compiler?
I'm running into an issue with std::ptr::fn_addr_eq(a as fn(), b as fn()) (which was stabilized in 1.85) as a replacement for a as fn() == b as fn(). In 1.85 there is also a new clippy lint that recommends the former rather than the latter.
Is there a way to use the new way on compilers with 1.85 or later while still using the old way on previous compilers?
EDIT: I thought I remember reading somewhere about an attribute to address this issue, but I can't recall where or what to search for. Everything I've looked for hasn't been helpful.
In the specific case of fn_addr_eq(), you should just use the old way — or define your own fn_addr_eq() function for specific cases — with an allow for the lint. This is because the purpose of fn_addr_eq() is to document what the code is doing, and a cfg conditional is overall making the code harder to comprehend, not easier.