open 1.3.3

Open a path or URL using the program configured on the system
Documentation

Use this library to open a path or URL using the program configured on the system.

Usage

The following should open the given URL in a web browser

extern crate open;

# #[test]
# fn doit() {
open::that("http://rust-lang.org").unwrap();
# }

Notes

As an operating system program is used, chances are that the open operation fails. Therefore, you are advised to at least check the result with .is_err() and behave accordingly, e.g. by letting the user know what you tried to open, and failed.

# fn doit() {
match open::that("http://rust-lang.org") {
Ok(exit_status) => {
if exit_status.success() {
println!("Look at your browser!");
} else {
if let Some(code) = exit_status.code() {
println!("Command returned non-zero exit status {}!", code);
} else {
println!("Command returned with unknown exit status!");
}
}
}
Err(why) => println!("Failure to execute command: {}", why),
}
# }