]> git.lizzy.rs Git - rust.git/blob - src/test/run-make-fulldeps/coverage-llvmir/testprog.rs
Merge commit 'fdb84cbfd25908df5683f8f62388f663d9260e39' into clippyup
[rust.git] / src / test / run-make-fulldeps / coverage-llvmir / testprog.rs
1 pub fn will_be_called() -> &'static str {
2     let val = "called";
3     println!("{}", val);
4     val
5 }
6
7 pub fn will_not_be_called() -> bool {
8     println!("should not have been called");
9     false
10 }
11
12 pub fn print<T>(left: &str, value: T, right: &str)
13 where
14     T: std::fmt::Display,
15 {
16     println!("{}{}{}", left, value, right);
17 }
18
19 pub fn wrap_with<F, T>(inner: T, should_wrap: bool, wrapper: F)
20 where
21     F: FnOnce(&T)
22 {
23     if should_wrap {
24         wrapper(&inner)
25     }
26 }
27
28 fn main() {
29     let less = 1;
30     let more = 100;
31
32     if less < more {
33         wrap_with(will_be_called(), less < more, |inner| print(" ***", inner, "*** "));
34         wrap_with(will_be_called(), more < less, |inner| print(" ***", inner, "*** "));
35     } else {
36         wrap_with(will_not_be_called(), true, |inner| print("wrapped result is: ", inner, ""));
37     }
38 }