mindustry logic execution, map- and schematic- parsing and rendering
Diffstat (limited to 'lemu/src/debug/mod.rs')
| -rw-r--r-- | lemu/src/debug/mod.rs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/lemu/src/debug/mod.rs b/lemu/src/debug/mod.rs index ef22b45..4d7ba0a 100644 --- a/lemu/src/debug/mod.rs +++ b/lemu/src/debug/mod.rs @@ -1,2 +1,24 @@ pub mod info; pub mod printable; + +/// kill me +pub fn ff(f: f64) -> String { + let mut s = f.to_string().into_bytes(); + if let Some((dot, _)) = s.iter().enumerate().find(|&(_, b)| *b == b'.') { + let mut real = 0; + for b in &mut s[dot..].iter_mut().skip(1) { + match b { + _ if real > 4 => { + s.truncate(dot + real); + break; + } + b'1'..=b'9' => real += 1, + _ => { + s.truncate(dot + real); + break; + } + } + } + } + String::from_utf8(s).unwrap() +} |