[][src]Crate open

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


The following should open the given URL in a web browser

extern crate open;



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.

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),



Convenience function for opening the passed path in a new thread. See documentation of that(...) for more details.