Rust Program to Use an Iterator to Traverse the Vector Elements

In this tutorial, we will learn Rust Program to Use an Iterator to Traverse the Vector Elements

Rust Program to Use an Iterator to Traverse the Vector Elements

Rust Program to Use an Iterator to Traverse the Vector Elements

// Rust program to use of an iterator to 
// traverse the vector elements

fn main() 
{
   	let countries = vec!["India", "UK", "USA", "Canada"];
   
   	println!("Country names: ");
   	for country in countries.into_iter() 
   	{
		println!("  {}",country);
   	}
}
Country names: 
  India
  UK
  USA
  Canada

Final Words

I hope this article is a Rust Program to Use an Iterator to Traverse the Vector Elements Let me know in the comments section if you have any issues.

Hi, I'm Selva a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Deekshi. Here, I post about programming to help developers.

Share on:

Leave a Comment