Chain iterators by calling methods like .map(), .filter(), or .collect() sequentially on the iterator object to transform or process data in a single pass. This pattern is also used with async operations by chaining .await calls on futures, as seen in the trpl crate's page_title function.
let response_text = trpl::get(url).await.text().await;
Html::parse(&response_text)
.select_first("title")
.map(|title| title.inner_html());
For standard collections, chaining works similarly with synchronous iterators:
let numbers = vec![1, 2, 3, 4, 5];
let sum: i32 = numbers.iter()
.filter(|&&x| x % 2 == 0)
.map(|x| x * 2)
.sum();