Poperton
Poperton

Reputation: 1796

How to import file from sibling folder in Rust

src/renderers/smart_video_renderer.rs
src/shaders/video_vertex.rs

I want to use video_vertex.rs in smart_video_renderer.rs. I tried:

use super::shaders::video_vertex::*

or

use shaders::video_vertex::*

but it won't import anyway.

I tried How do you use parent module imports in Rust? on which according to, it should be just use two::two; or in my case use shaders::shaders::... so I don't know what to do.

Upvotes: 3

Views: 688

Answers (1)

Gabriel Bitencourt
Gabriel Bitencourt

Reputation: 487

In your main.rs or lib.rs you need to declare shaders module with:

pub mod shaders;

And then inside shaders folder you need a mod.rs file with:

pub mod video_vertex;

Then you can use it inside src/renderers/smart_video_renderer.rs with:

use crate::shaders::video_vertex::*;

Upvotes: 2

Related Questions