2019-07-26 21:54:25 +00:00
|
|
|
// run-pass
|
|
|
|
|
2018-09-14 10:20:28 +00:00
|
|
|
#![allow(dead_code)]
|
2013-03-22 18:23:21 +00:00
|
|
|
// Check that functions can modify local state.
|
2012-05-11 20:09:19 +00:00
|
|
|
|
2015-03-22 20:13:15 +00:00
|
|
|
// pretty-expanded FIXME #23616
|
|
|
|
|
2015-03-26 00:06:52 +00:00
|
|
|
fn sums_to(v: Vec<isize> , sum: isize) -> bool {
|
2015-03-03 08:42:26 +00:00
|
|
|
let mut i = 0;
|
2013-06-05 04:43:41 +00:00
|
|
|
let mut sum0 = 0;
|
2012-05-11 20:09:19 +00:00
|
|
|
while i < v.len() {
|
2014-10-15 06:05:01 +00:00
|
|
|
sum0 += v[i];
|
2015-03-03 08:42:26 +00:00
|
|
|
i += 1;
|
2012-05-11 20:09:19 +00:00
|
|
|
}
|
2012-08-02 00:30:05 +00:00
|
|
|
return sum0 == sum;
|
2012-05-11 20:09:19 +00:00
|
|
|
}
|
|
|
|
|
2015-03-26 00:06:52 +00:00
|
|
|
fn sums_to_using_uniq(v: Vec<isize> , sum: isize) -> bool {
|
2015-03-03 08:42:26 +00:00
|
|
|
let mut i = 0;
|
2021-08-25 00:39:40 +00:00
|
|
|
let mut sum0: Box<_> = 0.into();
|
2012-05-11 20:09:19 +00:00
|
|
|
while i < v.len() {
|
2014-10-15 06:05:01 +00:00
|
|
|
*sum0 += v[i];
|
2015-03-03 08:42:26 +00:00
|
|
|
i += 1;
|
2012-05-11 20:09:19 +00:00
|
|
|
}
|
2012-08-02 00:30:05 +00:00
|
|
|
return *sum0 == sum;
|
2012-05-11 20:09:19 +00:00
|
|
|
}
|
|
|
|
|
2015-03-26 00:06:52 +00:00
|
|
|
fn sums_to_using_rec(v: Vec<isize> , sum: isize) -> bool {
|
2015-03-03 08:42:26 +00:00
|
|
|
let mut i = 0;
|
2013-06-05 04:43:41 +00:00
|
|
|
let mut sum0 = F {f: 0};
|
2012-05-11 20:09:19 +00:00
|
|
|
while i < v.len() {
|
2014-10-15 06:05:01 +00:00
|
|
|
sum0.f += v[i];
|
2015-03-03 08:42:26 +00:00
|
|
|
i += 1;
|
2012-05-11 20:09:19 +00:00
|
|
|
}
|
2012-08-02 00:30:05 +00:00
|
|
|
return sum0.f == sum;
|
2012-05-11 20:09:19 +00:00
|
|
|
}
|
|
|
|
|
2013-01-26 06:46:32 +00:00
|
|
|
struct F<T> { f: T }
|
|
|
|
|
2015-03-26 00:06:52 +00:00
|
|
|
fn sums_to_using_uniq_rec(v: Vec<isize> , sum: isize) -> bool {
|
2015-03-03 08:42:26 +00:00
|
|
|
let mut i = 0;
|
2021-08-25 00:39:40 +00:00
|
|
|
let mut sum0 = F::<Box<_>> {f: 0.into() };
|
2012-05-11 20:09:19 +00:00
|
|
|
while i < v.len() {
|
2014-10-15 06:05:01 +00:00
|
|
|
*sum0.f += v[i];
|
2015-03-03 08:42:26 +00:00
|
|
|
i += 1;
|
2012-05-11 20:09:19 +00:00
|
|
|
}
|
2012-08-02 00:30:05 +00:00
|
|
|
return *sum0.f == sum;
|
2012-05-11 20:09:19 +00:00
|
|
|
}
|
|
|
|
|
2013-02-02 03:43:17 +00:00
|
|
|
pub fn main() {
|
2013-02-14 19:47:00 +00:00
|
|
|
}
|