liveBook · Manning

Parsing

As explained in Refactoring to Rust

parse is a Rust string operation that converts textual data into a value of an inferred or specified target type.

Parsing converts a string slice into a value of a target type. In an RPN calculator, each non-operator term is parsed as an integer before being pushed onto a stack. section 3.2.3

Parsing RPN numbers

For `3 4 hello`, parsing produces `NUM 3` and `NUM 4`, then returns an error for `hello`; valid numbers can be pushed onto the evaluation stack.

How Refactoring to Rust covers it

How deep it goes
Explains generic target selection and parse-error handling, but stops short of parsing internals.
Examples
Demonstrates parsing operands such as `3` and `4`, rejecting `hello`, and feeding valid values into an RPN stack.
What it assumes
Assumes string splitting and matching, while demonstrating explicit and inferred integer targets.
What you can do after
Build it from scratch by parsing calculator operands and propagating invalid-number errors.
How it connects
Connects parsing with string slices, pattern matching, error handling, and stack-based expression evaluation.

Also explained in

Compare how 13 books explain parsing →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Refactoring to Rust. The section links point to the parts of the book it draws on.