Due to the way to manage variables in Heap and Stack, Rust does not provide a universal method like indexof()
for finding the index of an element in an array.
iter()
and position()
methods will come to the rescue.
Below few articles and a Github Repo that could help :
- Rust | How to find the index of an element in an array? by Andreas Reales
- Return the index of an element answer posted by Cuviper in the rust-lang forum
- Indexing Strings in Rust and TypeScript: A Case Study of String article written by Daw-Chih Liou
- The Caesar cypher little algo repo made by fzingg (myself)