Granted, these two code blocks (below) are far from identical, however the unittest idea (from JUnit) is alive and well in Rust, which should be encouraging. You'll need another crate (module, use cargo install) if you want AlmostEqual type assertions for floating point work. I'm doing a lot with f64. A reason to wrap these in a single curriculum is one is Agile and one is System (as we sometimes say) and although I haven't done it myself yet, I see teachers on Youtube extending Python with Rust. The Rust language aims to compete in the C++ area e.g. as the basis for a future Mozilla browser (Servo). A lot about it is familiar to Pythonistas. Synergy is already happening. Webassembly. Likely some code schools are already planning a Rust & Python & JavaScript based track. I'm dabbling in that also, in the context of my quirky Oregon high schoolish PATH | STEM curriculum. https://worldgame.blogspot.com/2019/12/updates-from-ocn.html Python: def test_e_module(self): e0 = D e1 = root3 * PHI**-1 e2 = rt2((5 - root5)/2) e3 = (3 - root5)/2 e4 = rt2(5 - 2*root5) e5 = 1/PHI tet = Tetrahedron(e0, e1, e2, e3, e4, e5) self.assertTrue(1/23 > tet.ivm_volume()/8 > 1/24, "Wrong E-mod") Rust: #[test] fn emod() { let s3: f64 = (9.0_f64/8.0).sqrt(); let phi: f64 = (1.0 + 5_f64.sqrt())/2.0; let edges = tetrahedron::emod(); let super_rt = 20.0 * s3; println!("{} {} {}", s3, super_rt, edges.volume()); approx::assert_abs_diff_eq!(edges.volume(), super_rt* (1.0/120.0) * (1.0/phi.powf(3.0))); }
participants (1)
-
kirby urner