Argumentos del Programa - Rust By Example
Description: Rust by Example (RBE) is a collection of runnable examples that illustrate various Rust concepts and standard libraries.

## Keyboard shortcuts

Press `←` or `→` to navigate between chapters

Press `S` or `/` to search in the book

Press `?` to show this help

Press `Esc` to hide this help

# Argumentos del Programa

## Standard Library

The command line arguments can be accessed using `std::env::args`, which returns an iterator that yields a `String` for each argument:

    use std::env;

    fn main() {
        let args: Vec<String> = env::args().collect();

        // The first argument is the path that was used to call the program.
        println!("My path is {}.", args[0]);

        // The rest of the arguments are the passed command line parameters.
        // Call the program like this:
        //   $ ./args arg1 arg2
        println!("I got {:?} arguments: {:?}.", args.len() - 1, &args[1..]);
    }

    $ ./args 1 2 3
    My path is ./args.
    I got 3 arguments: ["1", "2", "3"].

## Crates

Alternatively, there are numerous crates that can provide extra functionality when creating command-line applications. One of the more popular command line argument crates being `clap`.