Skip to Content
Hands-On Data Structures and Algorithms with Rust
book

Hands-On Data Structures and Algorithms with Rust

by Claus Matzinger
January 2019
Intermediate to advanced
316 pages
8h 8m
English
Packt Publishing
Content preview from Hands-On Data Structures and Algorithms with Rust

Linear searches

Linear searching is a fancy name for something that we do in almost every program and our everyday lives: going through a collection of items to find the first match. There is no need for any preprocessing or similar steps; the collection can be used as-is, which means that standard libraries commonly provide a generic implementation already. In Rust's case, the iterator trait offers this feature with functions called position() (or rposition()), find(), filter(), or even any(). fold() can also be used to find the thing you are looking for. The following is a diagram of the process:

Fundamentally, however, it's a loop over ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Hands-On Data Structures and Algorithms in Rust

Hands-On Data Structures and Algorithms in Rust

Matthew Stoodley

Publisher Resources

ISBN: 9781788995528Supplemental Content