Rust Program to Import a Module Using the ‘Use’ Keyword

Using this article, you can implement this Rust Program to Import a Module Using the ‘Use’ Keyword here. We will start the discussion below to successfully implement this task.

Rust Program to Import a Module Using the ‘Use’ Keyword

Rust Program to Import a Module Using the ‘Use’ Keyword

// Rust program to import a module 
// using the "use" keyword

pub mod Sample {
   pub fn sayHello(name:String) {
      println!("Hello {}",name);
   }
}

use Sample::sayHello;

fn main(){
   sayHello("Herry Potter".to_string());
}
Hello Herry Potter

Final Words

I hope this article helps you to understand Rust Program to Import a Module Using the ‘Use’ Keyword. If you encounter any issues let me know via the comment section.

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

Share on:

Leave a Comment