Skip to Main Content
Rust Programming Cookbook
book

Rust Programming Cookbook

by Claus Matzinger
October 2019
Intermediate to advanced content levelIntermediate to advanced
444 pages
10h 37m
English
Packt Publishing
Content preview from Rust Programming Cookbook

How to do it...

A simple program that uses command-line arguments to print directories/files only requires a few steps:

  1. Open a Terminal to create a new project using cargo new command-line-args . Use VS Code to open the project directory.
  2. First, let's adapt Cargo.toml to download clap and to have a better binary output name:
[package]name = "list"version = "1.0.0"authors = ["Claus Matzinger <claus.matzinger+kb@gmail.com>"]edition = "2018"# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html[dependencies]clap = {version= "2.33", features = ["suggestions", "color"]}
  1. In src/main.rs, we are going to start with imports:
use clap::{App, Arg, SubCommand};use std::fs::DirEntry;use std::path::Path;use ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Rust Web Programming

Rust Web Programming

Maxwell Flitton
The Complete Rust Programming Reference Guide

The Complete Rust Programming Reference Guide

Rahul Sharma, Vesa Kaihlavirta, Claus Matzinger

Publisher Resources

ISBN: 9781789530667Supplemental Content