The use-me-but-call-me-something-else approach

This is very similar to referring to the crate by another name:

use my_crate::module_name as mod_name; 

This doesn't mean what you probably think it means. With the crate example, we said that we are going to use my_crate, which is the cast of crate_name. In this case, what we're saying is that mod_name is a cast of my_crate::module_name.

Let's use the following after the preceding line:

use my_crate::module_name; 
let foo = module_name::print_me(10f32); 

If we do so, we now use the following:

let foo = mod_name::print_me(10f32); 

It looks the same, but really it means the following:

let foo = my_crate::module_name::print_me(10f32); 
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset