Include crates with :crates '((regex . 0.2))
syntax.
However there is a bug in org-babel that only lets you use decimal versions, not semver. Shave off the bugfix suffix.
I opened an issue here brotzeit/rustic#176 with a PR to fix here brotzeit/rustic#180
extern crate regex;
use regex::Regex;
fn main() {
let re = Regex::new(r"^\d{4}-\d{2}-\d{2}$").unwrap();
println!("{:?}", re.is_match("2014-01-01"));
}
use rayon::prelude::*;
fn sum_of_squares(input: &[i32]) -> i32 {
input.par_iter().map(|&i| i * i).sum()
}
fn main() {
println!("{:?}", sum_of_squares(&[10, 20, 30]));
}
- https://doc.rust-lang.org/std/process/struct.Command.html
- https://stackoverflow.com/questions/21011330/how-do-i-invoke-a-system-command-in-rust-and-capture-its-output
data comes back as a byte string, which will look a lot like an array of ints. Cast it with String::from_utf8_lossy()
.
use std::process::Command;
fn main() {
let output = Command::new("uname")
.arg("-a")
.output()
.expect("Failed to execute command");
println!("{:?}", String::from_utf8_lossy(&output.stdout));
}