How to import file from sibling folder in Rust

Viewed 377
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.

1 Answers

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::*;
Related