Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #![cfg_attr(feature = "const-fn", feature(const_fn))]
- #[cfg(feature = "foo")]
- fn foo() {
- println!("its foo");
- }
- #[cfg(not(feature = "foo"))]
- fn foo() {
- println!("its not foo");
- }
- macro_rules! const_fn {
- ($($f:tt)*) => (
- #[cfg(feature = "const-fn")]
- const $($f)*
- #[cfg(not(feature = "const-fn"))]
- $($f)*
- );
- }
- struct A;
- impl A {
- const_fn!(fn new() -> A { A });
- }
- fn main() {
- foo();
- let a = A::new();
- }
Add Comment
Please, Sign In to add comment