File not found Error

Hi,i am new to Rust programming language.
I have three files,, is the main file in where my main function exist.
In ,structure declaration and definition is there.In file i am using the file by calling "mod c" but compiler throws error by saying file c does not exist.
Any one please help me to sort out this issue.
Thanks in advance

You need to put the mod c; declaration in your or To access it from, you can use use crate::c::MyStruct;.

If you put mod c; in, it will look for the file src/b/

i want to use the structure defined in file in the file

Sure, so do like I described.

// src/ or src/
mod b;
mod c;
// src/
pub struct MyStruct {}
// src/
use crate::c::MyStruct;

It throws an error as use of undeclared type or module c

Please post the full error.

You access it with crate::c, not with just c. Additionally, what is value?

value is the structure variable

You can't really define mutable global variables in Rust.

Hi Thanks for your support .it's compiling now.
But still i didn't understand the usage of crate.

The word crate refers to your own project.

// Standard library
use std::some::thing;

// Your project
use crate::your::thing;
1 Like

You can't really define mutable global variables in Rust.

is it possible to use Global structure variable in Rust like c programming Lnguage???

There are some ways but if you are new to the language, I suggest you don't do it.


If i want to modify the data of the single structure in different files.Then what is the best method to do so.can u give me a better suggestion??/

You can pass a reference to it as an argument.


For starters ...any reference books???

The Rust book talks about references in chapter four.

1 Like

I did not configure the Cargo.toml file..

I am using Linux system ,i created one folder in that folder i created,, files
and i compile the file using rustc