Rust Online IDE & Code Editor for Technical Interviews
Running Rust 1.59 (2021 Edition) - IntelliSense is not available
Rust builds with Cargo and ships a few crates:anyhow = 1.0.32
bitflags = 1.2.1
chrono = 0.4.18
itertools = 0.9.0
nom = 5.1.2
rand = 0.7.3
rayon = 1.4.0
reqwest = 0.10.8
regex = 1.3.9
serde = 1.0.116
serde_json = 1.0.57
time = 0.2.22
url = 2.1.1
uuid = 0.8.1
Remember to declare crate dependencies with extern
, like so:
extern crate regex;
use regex::Regex;
fn main() {
let re = Regex::new(r"^\d{4}-\d{2}-\d{2}$").unwrap();
println!("Did our date match? {}", re.is_match("2014-01-01"));
}
Code language: Rust (rust)
You can use some basic asserts for testing as well:
fn main() {
assert!(true, "check boolean");
assert_eq!(2, 2, "compare numbers");
assert_eq!("abc", "abc", "compare strings");
assert_eq!([1,2,3], [1,2,3], "compare lists");
}
Code language: Rust (rust)