Created
August 17, 2017 14:51
-
-
Save oyvindln/d9f876c43f284cb387a8d4ff112ce7ff to your computer and use it in GitHub Desktop.
const
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![crate_type = "lib"] | |
#![feature(const_fn)] | |
const fn foo() -> usize { | |
10 | |
} | |
// Ends up as simply return 25 in the mir output. | |
pub fn test1<T>() -> usize { | |
if true { | |
25 | |
} else { | |
99 | |
} | |
} | |
// This does not. | |
pub fn test2<T>() -> usize { | |
if foo() < 32 { | |
25 | |
} else { | |
99 | |
} | |
} | |
// Neither does this. | |
pub fn test3<T>() -> usize { | |
if 10 < 32 { | |
25 | |
} else { | |
99 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment