head.daveops.net

Snippets for yer computer needs

Rust

Rust

https://doc.rust-lang.org/core/

Writing tests

If the function passes, the test passes

#[test]
fn this_tests_code(){
	println!("");
	if 1 == 0 {
		fail!("This should never happen");
	}
}

To compile the tests and replace main with test runner:

rustc --test test.rs

https://doc.rust-lang.org/stable/book/testing.html

Syntax cheatsheet

fn main() {
	let mut a = 1; // mut makes the value mutable
	a = 2;
	println!("{}", a);
}

Resources