1 //! # Chapter 0: Introduction 2 //! 3 //! This tutorial assumes that you are: 4 //! - Already familiar with Rust 5 //! - Using `winnow` for the first time 6 //! 7 //! The focus will be on parsing in-memory strings (`&str`). Once done, you might want to check the 8 //! [Special Topics][_topic] for more specialized topics or examples. 9 //! 10 //! ## About 11 //! 12 //! `winnow` is a parser-combinator library. In other words, it gives you tools to define: 13 //! - "parsers", or functions that take an input and give back an output 14 //! - "combinators", or functions that take parsers and _combine_ them together! 15 //! 16 //! While "combinator" might be an unfamiliar word, you are likely using them in your rust code 17 //! today, like with the [`Iterator`] trait: 18 //! ```rust 19 //! let data = vec![1, 2, 3, 4, 5]; 20 //! let even_count = data.iter() 21 //! .copied() // combinator 22 //! .filter(|d| d % 2 == 0) // combinator 23 //! .count(); // combinator 24 //! ``` 25 //! 26 //! Parser combinators are great because: 27 //! 28 //! - Individual parser functions are small, focused on one thing, ignoring the rest 29 //! - You can write tests focused on individual parsers (unit tests and property-based tests) 30 //! in addition to testing the top-level parser as a whole. 31 //! - Top-level parsing code looks close to the grammar you would have written 32 33 #![allow(unused_imports)] 34 use crate::_topic; 35 use std::iter::Iterator; 36 37 pub use super::chapter_1 as next; 38 pub use crate::_tutorial as table_of_contents; 39