liveBook · Manning

Chapter 23: Unfinished projects: Projects for you to finish

What you will learn in chapter 23 of Learn Rust in a Month of Lunches

The chapter introduces runnable but deliberately minimal projects for readers to develop further and explains why they need to be run locally rather than in the Playground.

After this chapter you will be able to

What it builds on

Section by section

Introduction

The chapter introduces runnable but deliberately minimal projects for readers to develop further and explains why they need to be run locally rather than in the Playground.

Key terms: unfinished projects, cargo run, basic functionality, crates, command-line interfaces (CLIs), graphical user interfaces (GUIs), Playground, system resources

23.1 Setup for the last two chapters

The section explains why the six unfinished projects are presented in four stages rather than showing the full code after each addition.

23.2 Typing tutor

Introduces the typing tutor project and describes what the finished app is meant to do.

Key terms: typing tutor, text file, typing test

23.2.1 Setup and first code

Introduces Crossterm for the typing tutor and shows what its keyboard input events look like when read in a loop.

Key terms: Crossterm, keyboard input, read(), pressing keys, releasing keys, shift

23.2.2 Developing the code

This section selects key-press events for a typing tutor, loads text for the user to copy, and shows why the current output needs cleanup.

Key terms: Event, Key, if let, KeyEvent, code, kind, typing.txt, read_to_string(), String, user_input

23.2.3 Further development and cleanup

This section explains how to clear and update the typing tutor’s display, mark typing mistakes, count correct characters, and tidy the code.

Key terms: Crossterm, execute!, Clear, ClearType::All, .zip(), iterator, content to type, user’s output, .unwrap(), question mark operator

23.2.4 Over to you

This section offers ways to extend the typing tutor and explains why input should stop growing at the end of the test text.

Key terms: user_input, file_content, backspace

23.3 Wikipedia article summary searcher

Introduces a Wikipedia summary-search project and explains why its API is easy to try.

Key terms: Wikipedia API, endpoint, summary, PAGE_NAME_HERE

23.3.1 Setup and first code

Sets up the Wikipedia summary searcher and shows that its first version receives Wikipedia responses but still needs to make them readable.

Key terms: App, user_input, Enter, JSON response, crossterm, reqwest, ureq, compiling time

23.3.2 Developing the code

The section selects useful fields from a Wikipedia JSON response and converts them into a readable Rust struct.

Key terms: title, description, extract, Deserialize, serde, serde_json

23.3.3 Further development and cleanup

This subsection refactors the Wikipedia article searcher to handle errors with `?` and make its output cleaner.

Key terms: .unwrap(), question mark operator, Box<dyn Error>, Result<(), Box<dyn Error>>, get_article(), Display, App struct

23.3.4 Over to you

Identifies ways to improve the working Wikipedia summary searcher, especially its error feedback and language options.

Key terms: error info, broken internet connection, switch languages

23.4 Terminal stopwatch and clock

Introduces a terminal-based stopwatch and clock project and explains the appeal of crates for building terminal interfaces.

Key terms: Crossterm, terminal-based app, TUI, cargo run

23.4.1 Setup and first code

The section sets up a ratatui terminal interface by explaining its drawing loop, a two-part layout, and the widgets rendered into it.

Key terms: ratatui, tui, crossterm, backend, Terminal, .draw(), closure, .render_widget(), Layout, direction

23.4.2 Developing the code

This section builds a readable clock and a three-state stopwatch, then keeps the terminal display updating without waiting for a key press.

Key terms: chrono, DateTime, .format(), UTC datetime, enum, Not started, Running, Stopped, Instant, Instant::now()

23.4.3 Further development and cleanup

This section cleans up the terminal stopwatch and clock by changing error handling and extracting helper functions, while weighing the readability costs of refactoring.

Key terms: .unwrap(), question mark operator, anyhow, Result<(), anyhow::Error>, helper function, Block, formatted UTC time, readability cleanup

23.4.4 Over to you

Suggests ways to improve the terminal stopwatch and clock’s display, add features, and avoid unnecessary work.

Key terms: stopwatch, display, Event, crossterm, FocusGained, FocusLost, String, NotStarted, Done, allocate memory

23.5 Summary

Concepts explained in this chapter

← Chapter 22: Writing your own macros Chapter 24: Unfinished projects, continued →

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.