|
1 | 1 | extern crate nyx_space as nyx;
|
| 2 | +use std::fmt::Write; |
2 | 3 |
|
3 | 4 | #[test]
|
4 | 5 | fn event_tracker_true_anomaly() {
|
@@ -35,8 +36,10 @@ fn event_tracker_true_anomaly() {
|
35 | 36 | let found_events = traj.find_all(e).unwrap();
|
36 | 37 | let pretty = found_events
|
37 | 38 | .iter()
|
38 |
| - .map(|orbit| format!("{:x}\tevent value: {}\n", orbit, e.eval(orbit))) |
39 |
| - .collect::<String>(); |
| 39 | + .fold(String::new(), |mut output, orbit| { |
| 40 | + let _ = writeln!(output, "{orbit:x}\tevent value: {}", e.eval(orbit)); |
| 41 | + output |
| 42 | + }); |
40 | 43 | println!("[ta_tracker] {} =>\n{}", e, pretty);
|
41 | 44 | }
|
42 | 45 |
|
@@ -89,32 +92,34 @@ fn event_tracker_true_anomaly() {
|
89 | 92 |
|
90 | 93 | let pretty = umbra_events
|
91 | 94 | .iter()
|
92 |
| - .map(|orbit| { |
93 |
| - format!( |
94 |
| - "{:x}\tevent value: {}\t(-10s: {}\t+10s: {})\n", |
| 95 | + .fold(String::new(), |mut output, orbit| { |
| 96 | + let _ = writeln!( |
| 97 | + output, |
| 98 | + "{:x}\tevent value: {}\t(-10s: {}\t+10s: {})", |
95 | 99 | orbit,
|
96 | 100 | &e_loc.compute(orbit),
|
97 | 101 | &e_loc.compute(&traj.at(orbit.epoch() - 10 * Unit::Second).unwrap()),
|
98 | 102 | &e_loc.compute(&traj.at(orbit.epoch() + 10 * Unit::Second).unwrap())
|
99 |
| - ) |
100 |
| - }) |
101 |
| - .collect::<String>(); |
| 103 | + ); |
| 104 | + output |
| 105 | + }); |
102 | 106 | println!("[eclipses] {} =>\n{}", umbra_event_loc, pretty);
|
103 | 107 |
|
104 | 108 | let penumbra_event_loc = e_loc.to_penumbra_event();
|
105 | 109 | let penumbra_events = traj.find_all(&penumbra_event_loc).unwrap();
|
106 | 110 |
|
107 | 111 | let pretty = penumbra_events
|
108 | 112 | .iter()
|
109 |
| - .map(|orbit| { |
110 |
| - format!( |
111 |
| - "{:x}\tevent value: {}\t(-10s: {}\t+10s: {})\n", |
| 113 | + .fold(String::new(), |mut output, orbit| { |
| 114 | + let _ = writeln!( |
| 115 | + output, |
| 116 | + "{:x}\tevent value: {}\t(-10s: {}\t+10s: {})", |
112 | 117 | orbit,
|
113 | 118 | &e_loc.compute(orbit),
|
114 | 119 | &e_loc.compute(&traj.at(orbit.epoch() - 10 * Unit::Second).unwrap()),
|
115 | 120 | &e_loc.compute(&traj.at(orbit.epoch() + 10 * Unit::Second).unwrap())
|
116 |
| - ) |
117 |
| - }) |
118 |
| - .collect::<String>(); |
| 121 | + ); |
| 122 | + output |
| 123 | + }); |
119 | 124 | println!("[eclipses] {} =>\n{}", penumbra_event_loc, pretty);
|
120 | 125 | }
|
0 commit comments