From dda4d791f07485f7e71e3f2197abdba3cce5493c Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Mon, 9 Mar 2026 17:04:39 -0700 Subject: [PATCH] Switch from hello world to a program that prints a usage string OK, so it's not much more than "hello, world", but it just show how to use std::env as well as Vec and even has an actual condition in it! It's almost like real programming now. Oh, and of course there's the collect() call which showcases both an iterator and the magic of rust's type inference here (telling collect() to return a Vec). So, there's quite a bit of rust here, even for just a tiny block of code. --- src/main.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index e7a11a9..34e2214 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,7 @@ fn main() { - println!("Hello, world!"); + let args: Vec = std::env::args().collect(); + if args.len() < 2 { + eprintln!("Usage: {} ", args[0]); + std::process::exit(1); + } } -- 2.45.2